copy = call(
"copy", "deepcopy",
- Py_BuildValue("OO", *object, memo)
+ PyTuple_Pack(2, *object, memo)
);
if (!copy)
return 0;
#else
result = call(
"string", "join",
- Py_BuildValue("OO", list, joiner)
+ PyTuple_Pack(2, list, joiner)
);
#endif
Py_DECREF(joiner);
/* not a literal; hand it over to the template compiler */
filter = call(
SRE_MODULE, "_subx",
- Py_BuildValue("OO", self, template)
+ PyTuple_Pack(2, self, template)
);
if (!filter)
return NULL;
match = pattern_new_match(self, &state, 1);
if (!match)
goto error;
- args = Py_BuildValue("(O)", match);
+ args = PyTuple_Pack(1, match);
if (!args) {
Py_DECREF(match);
goto error;
/* delegate to Python code */
return call(
SRE_MODULE, "_expand",
- Py_BuildValue("OOO", self->pattern, self, template)
+ PyTuple_Pack(3, self->pattern, self, template)
);
}
Py_XDECREF(v1);
return NULL;
}
- ret = Py_BuildValue("(OO)", v0, v1);
+ ret = PyTuple_Pack(2, v0, v1);
Py_DECREF(v0);
Py_DECREF(v1);
return ret;
Py_DECREF(v);
}
} else if (initial != NULL && PyString_Check(initial)) {
- PyObject *t_initial = Py_BuildValue("(O)",
+ PyObject *t_initial = PyTuple_Pack(1,
initial);
PyObject *v =
array_fromstring((arrayobject *)a,
PyObject *tp, *v, *tb;
PyErr_Fetch(&tp, &v, &tb);
- if ((r=Py_BuildValue("OOO",v,cls,args))) {
+ if ((r=PyTuple_Pack(3,v,cls,args))) {
Py_XDECREF(v);
v=r;
}
tmp = PyObject_CallFunction(joiner, "O", args);
UNLESS (tmp) return NULL;
- args = Py_BuildValue("(O)", tmp);
+ args = PyTuple_Pack(1, tmp);
Py_DECREF(tmp);
UNLESS (args) return NULL;
_PyDateTime_TIME_DATASIZE);
if (basestate != NULL) {
if (! HASTZINFO(self) || self->tzinfo == Py_None)
- result = Py_BuildValue("(O)", basestate);
+ result = PyTuple_Pack(1, basestate);
else
- result = Py_BuildValue("OO", basestate, self->tzinfo);
+ result = PyTuple_Pack(2, basestate, self->tzinfo);
Py_DECREF(basestate);
}
return result;
_PyDateTime_DATETIME_DATASIZE);
if (basestate != NULL) {
if (! HASTZINFO(self) || self->tzinfo == Py_None)
- result = Py_BuildValue("(O)", basestate);
+ result = PyTuple_Pack(1, basestate);
else
- result = Py_BuildValue("OO", basestate, self->tzinfo);
+ result = PyTuple_Pack(2, basestate, self->tzinfo);
Py_DECREF(basestate);
}
return result;
Py_INCREF(g);
return ((PyObject *) g);
}
- arg = Py_BuildValue("(OO)", (PyObject *)g, g->ob_callback_arg);
+ arg = PyTuple_Pack(2, (PyObject *)g, g->ob_callback_arg);
if (arg == NULL)
return NULL;
res = PyEval_CallObject(g->ob_callback, arg);
if (base == NULL)
return loghelper(args, log, "d:log", arg);
- newargs = PyTuple_New(1);
+ newargs = PyTuple_Pack(1, arg);
if (newargs == NULL)
return NULL;
- Py_INCREF(arg);
- PyTuple_SET_ITEM(newargs, 0, arg);
num = loghelper(newargs, log, "d:log", arg);
Py_DECREF(newargs);
if (num == NULL)
return NULL;
- newargs = PyTuple_New(1);
+ newargs = PyTuple_Pack(1, base);
if (newargs == NULL) {
Py_DECREF(num);
return NULL;
}
- Py_INCREF(base);
- PyTuple_SET_ITEM(newargs, 0, base);
den = loghelper(newargs, log, "d:log", base);
Py_DECREF(newargs);
if (den == NULL) {
{
if ((p_f[2] = PyFile_FromFile(p_s[2], cmdstring, rd_mode, _PyPclose)) != NULL)
PyFile_SetBufSize(p_f[0], bufsize);
- f = Py_BuildValue("OOO", p_f[0], p_f[1], p_f[2]);
+ f = PyTuple_Pack(3, p_f[0], p_f[1], p_f[2]);
}
else
- f = Py_BuildValue("OO", p_f[0], p_f[1]);
+ f = PyTuple_Pack(2, p_f[0], p_f[1]);
/*
* Insert the files we've created into the process dictionary
if (n != 4)
CloseHandle(hChildStderrRdDup);
- f = Py_BuildValue("OO",p1,p2);
+ f = PyTuple_Pack(2,p1,p2);
Py_XDECREF(p1);
Py_XDECREF(p2);
file_count = 2;
PyFile_SetBufSize(p1, 0);
PyFile_SetBufSize(p2, 0);
PyFile_SetBufSize(p3, 0);
- f = Py_BuildValue("OOO",p1,p2,p3);
+ f = PyTuple_Pack(3,p1,p2,p3);
Py_XDECREF(p1);
Py_XDECREF(p2);
Py_XDECREF(p3);
value = Py_None;
Py_INCREF(value);
}
- arg = Py_BuildValue("(OOO)", type, value, traceback);
+ arg = PyTuple_Pack(3, type, value, traceback);
if (arg == NULL) {
PyErr_Restore(type, value, traceback);
return 0;
static int
update_cache(PyObject *pat)
{
- PyObject *tuple = Py_BuildValue("(O)", pat);
+ PyObject *tuple = PyTuple_Pack(1, pat);
int status = 0;
if (!tuple)
/* optimization */
ifdlist = PyList_New(0);
if (ifdlist) {
- ret = Py_BuildValue("OOO", ifdlist, ifdlist, ifdlist);
+ ret = PyTuple_Pack(3, ifdlist, ifdlist, ifdlist);
Py_DECREF(ifdlist);
}
}
if (PyErr_Occurred())
ret = NULL;
else
- ret = Py_BuildValue("OOO", ifdlist, ofdlist, efdlist);
+ ret = PyTuple_Pack(3, ifdlist, ofdlist, efdlist);
Py_DECREF(ifdlist);
Py_DECREF(ofdlist);
if (addr == NULL)
goto finally;
- res = Py_BuildValue("OO", sock, addr);
+ res = PyTuple_Pack(2, sock, addr);
finally:
Py_XDECREF(sock);
addrlen)))
goto finally;
- ret = Py_BuildValue("OO", buf, addr);
+ ret = PyTuple_Pack(2, buf, addr);
finally:
Py_XDECREF(addr);
if (!(f2 = PyString_FromStringAndSize(obcapture + fieldsize,
fieldsize)))
goto finally;
- ret = Py_BuildValue("(OO)", f1, f2);
+ ret = PyTuple_Pack(2, f1, f2);
finally:
Py_XDECREF(f1);
st = Py_SymtableString(str, filename, start);
if (st == NULL)
return NULL;
- t = Py_BuildValue("O", st->st_symbols);
+ t = st->st_symbols;
+ Py_INCREF(t);
PyMem_Free((void *)st->st_future);
PySymtable_Free(st);
return t;
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
return NULL;
PyErr_Clear();
- args = Py_BuildValue("(OO)", inst, name);
+ args = PyTuple_Pack(2, inst, name);
if (args == NULL)
return NULL;
res = PyEval_CallObject(func, args);
if (func == NULL)
return instance_setattr1(inst, name, v);
if (v == NULL)
- args = Py_BuildValue("(OO)", inst, name);
+ args = PyTuple_Pack(2, inst, name);
else
- args = Py_BuildValue("(OOO)", inst, name, v);
+ args = PyTuple_Pack(3, inst, name, v);
if (args == NULL)
return -1;
res = PyEval_CallObject(func, args);
func = instance_getattr(inst, getitemstr);
if (func == NULL)
return NULL;
- arg = Py_BuildValue("(O)", key);
+ arg = PyTuple_Pack(1, key);
if (arg == NULL) {
Py_DECREF(func);
return NULL;
if (func == NULL)
return -1;
if (value == NULL)
- arg = Py_BuildValue("(O)", key);
+ arg = PyTuple_Pack(1, key);
else
- arg = Py_BuildValue("(OO)", key, value);
+ arg = PyTuple_Pack(2, key, value);
if (arg == NULL) {
Py_DECREF(func);
return -1;
if (func) {
PyObject *res;
int ret;
- PyObject *arg = Py_BuildValue("(O)", member);
+ PyObject *arg = PyTuple_Pack(1, member);
if(arg == NULL) {
Py_DECREF(func);
return -1;
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
- args = Py_BuildValue("(O)", w);
+ args = PyTuple_Pack(1, w);
if (args == NULL) {
Py_DECREF(func);
return NULL;
return generic_binary_op(v, w, opname);
}
- args = Py_BuildValue("(O)", w);
+ args = PyTuple_Pack(1, w);
if (args == NULL) {
Py_DECREF(coercefunc);
return NULL;
return 1;
}
/* Has __coerce__ method: call it */
- args = Py_BuildValue("(O)", w);
+ args = PyTuple_Pack(1, w);
if (args == NULL) {
return -1;
}
return 2;
}
- args = Py_BuildValue("(O)", w);
+ args = PyTuple_Pack(1, w);
if (args == NULL) {
Py_DECREF(cmp_func);
return -2;
func = PyObject_GetAttrString(v, "__pow__");
if (func == NULL)
return NULL;
- args = Py_BuildValue("(OO)", w, z);
+ args = PyTuple_Pack(2, w, z);
if (args == NULL) {
Py_DECREF(func);
return NULL;
PyErr_Clear();
return instance_pow(v, w, z);
}
- args = Py_BuildValue("(OO)", w, z);
+ args = PyTuple_Pack(2, w, z);
if (args == NULL) {
Py_DECREF(func);
return NULL;
return res;
}
- args = Py_BuildValue("(O)", w);
+ args = PyTuple_Pack(1, w);
if (args == NULL) {
Py_DECREF(method);
return NULL;
mod = c_diff(v->cval, c_prod(w->cval, div));
d = PyComplex_FromCComplex(div);
m = PyComplex_FromCComplex(mod);
- z = Py_BuildValue("(OO)", d, m);
+ z = PyTuple_Pack(2, d, m);
Py_XDECREF(d);
Py_XDECREF(m);
return z;
if (f == NULL)
PyErr_Clear();
else {
- PyObject *args = Py_BuildValue("()");
+ PyObject *args = PyTuple_New(0);
if (args == NULL)
return NULL;
r = PyEval_CallObject(f, args);
if (reader == NULL)
return NULL;
if (n <= 0)
- args = Py_BuildValue("()");
+ args = PyTuple_New(0);
else
args = Py_BuildValue("(i)", n);
if (args == NULL) {
Py_DECREF(writer);
return -1;
}
- args = Py_BuildValue("(O)", value);
+ args = PyTuple_Pack(1, value);
if (args == NULL) {
Py_DECREF(value);
Py_DECREF(writer);
}
else {
PyObject* tuple;
- tuple = Py_BuildValue("OO", subclass, old_mro);
+ tuple = PyTuple_Pack(2, subclass, old_mro);
Py_DECREF(old_mro);
if (!tuple)
return -1;
for (i = 0; i < PyList_Size(temp); i++) {
PyTypeObject* cls;
PyObject* mro;
- PyArg_ParseTuple(PyList_GET_ITEM(temp, i),
- "OO", &cls, &mro);
+ PyArg_UnpackTuple(PyList_GET_ITEM(temp, i),
+ "", 2, 2, &cls, &mro);
Py_DECREF(cls->tp_mro);
cls->tp_mro = mro;
Py_INCREF(cls->tp_mro);
/* Adjust for empty tuple bases */
if (nbases == 0) {
- bases = Py_BuildValue("(O)", &PyBaseObject_Type);
+ bases = PyTuple_Pack(1, &PyBaseObject_Type);
if (bases == NULL)
return NULL;
nbases = 1;
/* Make it into a tuple */
if (PyString_Check(slots))
- slots = Py_BuildValue("(O)", slots);
+ slots = PyTuple_Pack(1, slots);
else
slots = PySequence_Tuple(slots);
if (slots == NULL) {
PyTuple_SET_ITEM(args2, i+1, v);
}
- res = Py_BuildValue("(OOOOO)",
- newobj, args2, state, listitems, dictitems);
+ res = PyTuple_Pack(5, newobj, args2, state, listitems, dictitems);
end:
Py_XDECREF(cls);
if (base == NULL)
bases = PyTuple_New(0);
else
- bases = Py_BuildValue("(O)", base);
+ bases = PyTuple_Pack(1, base);
if (bases == NULL)
goto error;
type->tp_bases = bases;
func = lookup_maybe(self, "__contains__", &contains_str);
if (func != NULL) {
- args = Py_BuildValue("(O)", value);
+ args = PyTuple_Pack(1, value);
if (args == NULL)
res = NULL;
else {
PyErr_Clear();
}
else {
- args = Py_BuildValue("(O)", other);
+ args = PyTuple_Pack(1, other);
if (args == NULL)
res = NULL;
else {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
- args = Py_BuildValue("(O)", other);
+ args = PyTuple_Pack(1, other);
if (args == NULL)
res = NULL;
else {
return NULL;
if (PyNumber_Coerce(&v, &w) < 0)
return NULL;
- res = Py_BuildValue("(OO)", v, w);
+ res = PyTuple_Pack(2, v, w);
Py_DECREF(v);
Py_DECREF(w);
return res;
good = item;
}
else {
- PyObject *arg = Py_BuildValue("(O)", item);
+ PyObject *arg = PyTuple_Pack(1, item);
if (arg == NULL) {
Py_DECREF(item);
goto Fail_1;
ok = 1;
} else {
PyObject *arg, *good;
- arg = Py_BuildValue("(O)", item);
+ arg = PyTuple_Pack(1, item);
if (arg == NULL) {
Py_DECREF(item);
goto Fail_1;
if (func == Py_None) {
ok = 1;
} else {
- arg = Py_BuildValue("(O)", item);
+ arg = PyTuple_Pack(1, item);
if (arg == NULL) {
Py_DECREF(item);
goto Fail_1;
x = NULL;
}
if (err == 0) {
- x = Py_BuildValue("(O)", v);
+ x = PyTuple_Pack(1, v);
if (x == NULL)
err = -1;
}
break;
}
u = TOP();
- w = Py_BuildValue("(OOOO)",
+ w = PyTuple_Pack(4,
w,
f->f_globals,
f->f_locals == NULL ?
value = Py_None;
Py_INCREF(value);
}
- arg = Py_BuildValue("(OOO)", type, value, traceback);
+ arg = PyTuple_Pack(3, type, value, traceback);
if (arg == NULL) {
PyErr_Restore(type, value, traceback);
return;
Py_None, line);
if (t == NULL)
goto exit;
- w = Py_BuildValue("(OO)", v, t);
+ w = PyTuple_Pack(2, v, t);
if (w == NULL)
goto exit;
PyErr_SetObject(exc, w);
PyObject *w, *t, *np=NULL;
long n;
- t = Py_BuildValue("(OO)", v, v->ob_type);
+ t = PyTuple_Pack(2, v, v->ob_type);
if (t == NULL)
goto fail;
w = PyDict_GetItem(dict, t);
PyObject *args, *res;
if (value == Py_None)
- args = Py_BuildValue("()");
+ args = PyTuple_New(0);
else if (PyTuple_Check(value)) {
Py_INCREF(value);
args = value;
}
else
- args = Py_BuildValue("(O)", value);
+ args = PyTuple_Pack(1, value);
if (args == NULL)
goto finally;
classname = PyString_FromString(dot+1);
if (classname == NULL)
goto failure;
- bases = Py_BuildValue("(O)", base);
+ bases = PyTuple_Pack(1, base);
if (bases == NULL)
goto failure;
result = PyClass_New(bases, dict, classname);
}
/* Now we need to pre-allocate a MemoryError instance */
- args = Py_BuildValue("()");
+ args = PyTuple_New(0);
if (!args ||
!(PyExc_MemoryErrorInst = PyEval_CallObject(PyExc_MemoryError, args)))
{
}
hook = PySys_GetObject("excepthook");
if (hook) {
- PyObject *args = Py_BuildValue("(OOO)",
+ PyObject *args = PyTuple_Pack(3,
exception, v ? v : Py_None, tb ? tb : Py_None);
PyObject *result = PyEval_CallObject(hook, args);
if (result == NULL) {