Simplify and speedup uses of Py_BuildValue():
* Py_BuildValue("(OOO)",a,b,c) --> PyTuple_Pack(3,a,b,c) * Py_BuildValue("()",a) --> PyTuple_New(0) * Py_BuildValue("O", a) --> Py_INCREF(a)
This commit is contained in:
parent
cb2da43db8
commit
8ae4689657
|
@ -1907,7 +1907,7 @@ deepcopy(PyObject** object, PyObject* memo)
|
||||||
|
|
||||||
copy = call(
|
copy = call(
|
||||||
"copy", "deepcopy",
|
"copy", "deepcopy",
|
||||||
Py_BuildValue("OO", *object, memo)
|
PyTuple_Pack(2, *object, memo)
|
||||||
);
|
);
|
||||||
if (!copy)
|
if (!copy)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1968,7 +1968,7 @@ join_list(PyObject* list, PyObject* pattern)
|
||||||
#else
|
#else
|
||||||
result = call(
|
result = call(
|
||||||
"string", "join",
|
"string", "join",
|
||||||
Py_BuildValue("OO", list, joiner)
|
PyTuple_Pack(2, list, joiner)
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
Py_DECREF(joiner);
|
Py_DECREF(joiner);
|
||||||
|
@ -2255,7 +2255,7 @@ pattern_subx(PatternObject* self, PyObject* template, PyObject* string,
|
||||||
/* not a literal; hand it over to the template compiler */
|
/* not a literal; hand it over to the template compiler */
|
||||||
filter = call(
|
filter = call(
|
||||||
SRE_MODULE, "_subx",
|
SRE_MODULE, "_subx",
|
||||||
Py_BuildValue("OO", self, template)
|
PyTuple_Pack(2, self, template)
|
||||||
);
|
);
|
||||||
if (!filter)
|
if (!filter)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2321,7 +2321,7 @@ pattern_subx(PatternObject* self, PyObject* template, PyObject* string,
|
||||||
match = pattern_new_match(self, &state, 1);
|
match = pattern_new_match(self, &state, 1);
|
||||||
if (!match)
|
if (!match)
|
||||||
goto error;
|
goto error;
|
||||||
args = Py_BuildValue("(O)", match);
|
args = PyTuple_Pack(1, match);
|
||||||
if (!args) {
|
if (!args) {
|
||||||
Py_DECREF(match);
|
Py_DECREF(match);
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -2610,7 +2610,7 @@ match_expand(MatchObject* self, PyObject* args)
|
||||||
/* delegate to Python code */
|
/* delegate to Python code */
|
||||||
return call(
|
return call(
|
||||||
SRE_MODULE, "_expand",
|
SRE_MODULE, "_expand",
|
||||||
Py_BuildValue("OOO", self->pattern, self, template)
|
PyTuple_Pack(3, self->pattern, self, template)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -901,7 +901,7 @@ alp_GetFrameTime(alpobject *self, PyObject *args)
|
||||||
Py_XDECREF(v1);
|
Py_XDECREF(v1);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ret = Py_BuildValue("(OO)", v0, v1);
|
ret = PyTuple_Pack(2, v0, v1);
|
||||||
Py_DECREF(v0);
|
Py_DECREF(v0);
|
||||||
Py_DECREF(v1);
|
Py_DECREF(v1);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -1770,7 +1770,7 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||||
Py_DECREF(v);
|
Py_DECREF(v);
|
||||||
}
|
}
|
||||||
} else if (initial != NULL && PyString_Check(initial)) {
|
} else if (initial != NULL && PyString_Check(initial)) {
|
||||||
PyObject *t_initial = Py_BuildValue("(O)",
|
PyObject *t_initial = PyTuple_Pack(1,
|
||||||
initial);
|
initial);
|
||||||
PyObject *v =
|
PyObject *v =
|
||||||
array_fromstring((arrayobject *)a,
|
array_fromstring((arrayobject *)a,
|
||||||
|
|
|
@ -3627,7 +3627,7 @@ Instance_New(PyObject *cls, PyObject *args)
|
||||||
PyObject *tp, *v, *tb;
|
PyObject *tp, *v, *tb;
|
||||||
|
|
||||||
PyErr_Fetch(&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);
|
Py_XDECREF(v);
|
||||||
v=r;
|
v=r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -439,7 +439,7 @@ O_writelines(Oobject *self, PyObject *args) {
|
||||||
tmp = PyObject_CallFunction(joiner, "O", args);
|
tmp = PyObject_CallFunction(joiner, "O", args);
|
||||||
UNLESS (tmp) return NULL;
|
UNLESS (tmp) return NULL;
|
||||||
|
|
||||||
args = Py_BuildValue("(O)", tmp);
|
args = PyTuple_Pack(1, tmp);
|
||||||
Py_DECREF(tmp);
|
Py_DECREF(tmp);
|
||||||
UNLESS (args) return NULL;
|
UNLESS (args) return NULL;
|
||||||
|
|
||||||
|
|
|
@ -3372,9 +3372,9 @@ time_getstate(PyDateTime_Time *self)
|
||||||
_PyDateTime_TIME_DATASIZE);
|
_PyDateTime_TIME_DATASIZE);
|
||||||
if (basestate != NULL) {
|
if (basestate != NULL) {
|
||||||
if (! HASTZINFO(self) || self->tzinfo == Py_None)
|
if (! HASTZINFO(self) || self->tzinfo == Py_None)
|
||||||
result = Py_BuildValue("(O)", basestate);
|
result = PyTuple_Pack(1, basestate);
|
||||||
else
|
else
|
||||||
result = Py_BuildValue("OO", basestate, self->tzinfo);
|
result = PyTuple_Pack(2, basestate, self->tzinfo);
|
||||||
Py_DECREF(basestate);
|
Py_DECREF(basestate);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -4350,9 +4350,9 @@ datetime_getstate(PyDateTime_DateTime *self)
|
||||||
_PyDateTime_DATETIME_DATASIZE);
|
_PyDateTime_DATETIME_DATASIZE);
|
||||||
if (basestate != NULL) {
|
if (basestate != NULL) {
|
||||||
if (! HASTZINFO(self) || self->tzinfo == Py_None)
|
if (! HASTZINFO(self) || self->tzinfo == Py_None)
|
||||||
result = Py_BuildValue("(O)", basestate);
|
result = PyTuple_Pack(1, basestate);
|
||||||
else
|
else
|
||||||
result = Py_BuildValue("OO", basestate, self->tzinfo);
|
result = PyTuple_Pack(2, basestate, self->tzinfo);
|
||||||
Py_DECREF(basestate);
|
Py_DECREF(basestate);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -1714,7 +1714,7 @@ forms_do_or_check_forms(PyObject *dummy, FL_OBJECT *(*func)(void))
|
||||||
Py_INCREF(g);
|
Py_INCREF(g);
|
||||||
return ((PyObject *) 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)
|
if (arg == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
res = PyEval_CallObject(g->ob_callback, arg);
|
res = PyEval_CallObject(g->ob_callback, arg);
|
||||||
|
|
|
@ -259,23 +259,19 @@ math_log(PyObject *self, PyObject *args)
|
||||||
if (base == NULL)
|
if (base == NULL)
|
||||||
return loghelper(args, log, "d:log", arg);
|
return loghelper(args, log, "d:log", arg);
|
||||||
|
|
||||||
newargs = PyTuple_New(1);
|
newargs = PyTuple_Pack(1, arg);
|
||||||
if (newargs == NULL)
|
if (newargs == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
Py_INCREF(arg);
|
|
||||||
PyTuple_SET_ITEM(newargs, 0, arg);
|
|
||||||
num = loghelper(newargs, log, "d:log", arg);
|
num = loghelper(newargs, log, "d:log", arg);
|
||||||
Py_DECREF(newargs);
|
Py_DECREF(newargs);
|
||||||
if (num == NULL)
|
if (num == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
newargs = PyTuple_New(1);
|
newargs = PyTuple_Pack(1, base);
|
||||||
if (newargs == NULL) {
|
if (newargs == NULL) {
|
||||||
Py_DECREF(num);
|
Py_DECREF(num);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
Py_INCREF(base);
|
|
||||||
PyTuple_SET_ITEM(newargs, 0, base);
|
|
||||||
den = loghelper(newargs, log, "d:log", base);
|
den = loghelper(newargs, log, "d:log", base);
|
||||||
Py_DECREF(newargs);
|
Py_DECREF(newargs);
|
||||||
if (den == NULL) {
|
if (den == NULL) {
|
||||||
|
|
|
@ -3376,10 +3376,10 @@ _PyPopen(char *cmdstring, int mode, int n, int bufsize)
|
||||||
{
|
{
|
||||||
if ((p_f[2] = PyFile_FromFile(p_s[2], cmdstring, rd_mode, _PyPclose)) != NULL)
|
if ((p_f[2] = PyFile_FromFile(p_s[2], cmdstring, rd_mode, _PyPclose)) != NULL)
|
||||||
PyFile_SetBufSize(p_f[0], bufsize);
|
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
|
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
|
* Insert the files we've created into the process dictionary
|
||||||
|
@ -4069,7 +4069,7 @@ _PyPopen(char *cmdstring, int mode, int n)
|
||||||
if (n != 4)
|
if (n != 4)
|
||||||
CloseHandle(hChildStderrRdDup);
|
CloseHandle(hChildStderrRdDup);
|
||||||
|
|
||||||
f = Py_BuildValue("OO",p1,p2);
|
f = PyTuple_Pack(2,p1,p2);
|
||||||
Py_XDECREF(p1);
|
Py_XDECREF(p1);
|
||||||
Py_XDECREF(p2);
|
Py_XDECREF(p2);
|
||||||
file_count = 2;
|
file_count = 2;
|
||||||
|
@ -4101,7 +4101,7 @@ _PyPopen(char *cmdstring, int mode, int n)
|
||||||
PyFile_SetBufSize(p1, 0);
|
PyFile_SetBufSize(p1, 0);
|
||||||
PyFile_SetBufSize(p2, 0);
|
PyFile_SetBufSize(p2, 0);
|
||||||
PyFile_SetBufSize(p3, 0);
|
PyFile_SetBufSize(p3, 0);
|
||||||
f = Py_BuildValue("OOO",p1,p2,p3);
|
f = PyTuple_Pack(3,p1,p2,p3);
|
||||||
Py_XDECREF(p1);
|
Py_XDECREF(p1);
|
||||||
Py_XDECREF(p2);
|
Py_XDECREF(p2);
|
||||||
Py_XDECREF(p3);
|
Py_XDECREF(p3);
|
||||||
|
|
|
@ -336,7 +336,7 @@ trace_frame_exc(PyThreadState *tstate, PyFrameObject *f)
|
||||||
value = Py_None;
|
value = Py_None;
|
||||||
Py_INCREF(value);
|
Py_INCREF(value);
|
||||||
}
|
}
|
||||||
arg = Py_BuildValue("(OOO)", type, value, traceback);
|
arg = PyTuple_Pack(3, type, value, traceback);
|
||||||
if (arg == NULL) {
|
if (arg == NULL) {
|
||||||
PyErr_Restore(type, value, traceback);
|
PyErr_Restore(type, value, traceback);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -551,7 +551,7 @@ static PyObject *cache_prog;
|
||||||
static int
|
static int
|
||||||
update_cache(PyObject *pat)
|
update_cache(PyObject *pat)
|
||||||
{
|
{
|
||||||
PyObject *tuple = Py_BuildValue("(O)", pat);
|
PyObject *tuple = PyTuple_Pack(1, pat);
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
if (!tuple)
|
if (!tuple)
|
||||||
|
|
|
@ -284,7 +284,7 @@ select_select(PyObject *self, PyObject *args)
|
||||||
/* optimization */
|
/* optimization */
|
||||||
ifdlist = PyList_New(0);
|
ifdlist = PyList_New(0);
|
||||||
if (ifdlist) {
|
if (ifdlist) {
|
||||||
ret = Py_BuildValue("OOO", ifdlist, ifdlist, ifdlist);
|
ret = PyTuple_Pack(3, ifdlist, ifdlist, ifdlist);
|
||||||
Py_DECREF(ifdlist);
|
Py_DECREF(ifdlist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -299,7 +299,7 @@ select_select(PyObject *self, PyObject *args)
|
||||||
if (PyErr_Occurred())
|
if (PyErr_Occurred())
|
||||||
ret = NULL;
|
ret = NULL;
|
||||||
else
|
else
|
||||||
ret = Py_BuildValue("OOO", ifdlist, ofdlist, efdlist);
|
ret = PyTuple_Pack(3, ifdlist, ofdlist, efdlist);
|
||||||
|
|
||||||
Py_DECREF(ifdlist);
|
Py_DECREF(ifdlist);
|
||||||
Py_DECREF(ofdlist);
|
Py_DECREF(ofdlist);
|
||||||
|
|
|
@ -1161,7 +1161,7 @@ sock_accept(PySocketSockObject *s)
|
||||||
if (addr == NULL)
|
if (addr == NULL)
|
||||||
goto finally;
|
goto finally;
|
||||||
|
|
||||||
res = Py_BuildValue("OO", sock, addr);
|
res = PyTuple_Pack(2, sock, addr);
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
Py_XDECREF(sock);
|
Py_XDECREF(sock);
|
||||||
|
@ -1911,7 +1911,7 @@ sock_recvfrom(PySocketSockObject *s, PyObject *args)
|
||||||
addrlen)))
|
addrlen)))
|
||||||
goto finally;
|
goto finally;
|
||||||
|
|
||||||
ret = Py_BuildValue("OO", buf, addr);
|
ret = PyTuple_Pack(2, buf, addr);
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
Py_XDECREF(addr);
|
Py_XDECREF(addr);
|
||||||
|
|
|
@ -157,7 +157,7 @@ svc_GetFields(captureobject *self, PyObject *args)
|
||||||
if (!(f2 = PyString_FromStringAndSize(obcapture + fieldsize,
|
if (!(f2 = PyString_FromStringAndSize(obcapture + fieldsize,
|
||||||
fieldsize)))
|
fieldsize)))
|
||||||
goto finally;
|
goto finally;
|
||||||
ret = Py_BuildValue("(OO)", f1, f2);
|
ret = PyTuple_Pack(2, f1, f2);
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
Py_XDECREF(f1);
|
Py_XDECREF(f1);
|
||||||
|
|
|
@ -31,7 +31,8 @@ symtable_symtable(PyObject *self, PyObject *args)
|
||||||
st = Py_SymtableString(str, filename, start);
|
st = Py_SymtableString(str, filename, start);
|
||||||
if (st == NULL)
|
if (st == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
t = Py_BuildValue("O", st->st_symbols);
|
t = st->st_symbols;
|
||||||
|
Py_INCREF(t);
|
||||||
PyMem_Free((void *)st->st_future);
|
PyMem_Free((void *)st->st_future);
|
||||||
PySymtable_Free(st);
|
PySymtable_Free(st);
|
||||||
return t;
|
return t;
|
||||||
|
|
|
@ -750,7 +750,7 @@ instance_getattr(register PyInstanceObject *inst, PyObject *name)
|
||||||
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
|
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
|
||||||
return NULL;
|
return NULL;
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
args = Py_BuildValue("(OO)", inst, name);
|
args = PyTuple_Pack(2, inst, name);
|
||||||
if (args == NULL)
|
if (args == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
res = PyEval_CallObject(func, args);
|
res = PyEval_CallObject(func, args);
|
||||||
|
@ -847,9 +847,9 @@ instance_setattr(PyInstanceObject *inst, PyObject *name, PyObject *v)
|
||||||
if (func == NULL)
|
if (func == NULL)
|
||||||
return instance_setattr1(inst, name, v);
|
return instance_setattr1(inst, name, v);
|
||||||
if (v == NULL)
|
if (v == NULL)
|
||||||
args = Py_BuildValue("(OO)", inst, name);
|
args = PyTuple_Pack(2, inst, name);
|
||||||
else
|
else
|
||||||
args = Py_BuildValue("(OOO)", inst, name, v);
|
args = PyTuple_Pack(3, inst, name, v);
|
||||||
if (args == NULL)
|
if (args == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
res = PyEval_CallObject(func, args);
|
res = PyEval_CallObject(func, args);
|
||||||
|
@ -1038,7 +1038,7 @@ instance_subscript(PyInstanceObject *inst, PyObject *key)
|
||||||
func = instance_getattr(inst, getitemstr);
|
func = instance_getattr(inst, getitemstr);
|
||||||
if (func == NULL)
|
if (func == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
arg = Py_BuildValue("(O)", key);
|
arg = PyTuple_Pack(1, key);
|
||||||
if (arg == NULL) {
|
if (arg == NULL) {
|
||||||
Py_DECREF(func);
|
Py_DECREF(func);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1069,9 +1069,9 @@ instance_ass_subscript(PyInstanceObject *inst, PyObject *key, PyObject *value)
|
||||||
if (func == NULL)
|
if (func == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
arg = Py_BuildValue("(O)", key);
|
arg = PyTuple_Pack(1, key);
|
||||||
else
|
else
|
||||||
arg = Py_BuildValue("(OO)", key, value);
|
arg = PyTuple_Pack(2, key, value);
|
||||||
if (arg == NULL) {
|
if (arg == NULL) {
|
||||||
Py_DECREF(func);
|
Py_DECREF(func);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1281,7 +1281,7 @@ instance_contains(PyInstanceObject *inst, PyObject *member)
|
||||||
if (func) {
|
if (func) {
|
||||||
PyObject *res;
|
PyObject *res;
|
||||||
int ret;
|
int ret;
|
||||||
PyObject *arg = Py_BuildValue("(O)", member);
|
PyObject *arg = PyTuple_Pack(1, member);
|
||||||
if(arg == NULL) {
|
if(arg == NULL) {
|
||||||
Py_DECREF(func);
|
Py_DECREF(func);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1346,7 +1346,7 @@ generic_binary_op(PyObject *v, PyObject *w, char *opname)
|
||||||
Py_INCREF(Py_NotImplemented);
|
Py_INCREF(Py_NotImplemented);
|
||||||
return Py_NotImplemented;
|
return Py_NotImplemented;
|
||||||
}
|
}
|
||||||
args = Py_BuildValue("(O)", w);
|
args = PyTuple_Pack(1, w);
|
||||||
if (args == NULL) {
|
if (args == NULL) {
|
||||||
Py_DECREF(func);
|
Py_DECREF(func);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1389,7 +1389,7 @@ half_binop(PyObject *v, PyObject *w, char *opname, binaryfunc thisfunc,
|
||||||
return generic_binary_op(v, w, opname);
|
return generic_binary_op(v, w, opname);
|
||||||
}
|
}
|
||||||
|
|
||||||
args = Py_BuildValue("(O)", w);
|
args = PyTuple_Pack(1, w);
|
||||||
if (args == NULL) {
|
if (args == NULL) {
|
||||||
Py_DECREF(coercefunc);
|
Py_DECREF(coercefunc);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1474,7 +1474,7 @@ instance_coerce(PyObject **pv, PyObject **pw)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/* Has __coerce__ method: call it */
|
/* Has __coerce__ method: call it */
|
||||||
args = Py_BuildValue("(O)", w);
|
args = PyTuple_Pack(1, w);
|
||||||
if (args == NULL) {
|
if (args == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1587,7 +1587,7 @@ half_cmp(PyObject *v, PyObject *w)
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
args = Py_BuildValue("(O)", w);
|
args = PyTuple_Pack(1, w);
|
||||||
if (args == NULL) {
|
if (args == NULL) {
|
||||||
Py_DECREF(cmp_func);
|
Py_DECREF(cmp_func);
|
||||||
return -2;
|
return -2;
|
||||||
|
@ -1747,7 +1747,7 @@ instance_pow(PyObject *v, PyObject *w, PyObject *z)
|
||||||
func = PyObject_GetAttrString(v, "__pow__");
|
func = PyObject_GetAttrString(v, "__pow__");
|
||||||
if (func == NULL)
|
if (func == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
args = Py_BuildValue("(OO)", w, z);
|
args = PyTuple_Pack(2, w, z);
|
||||||
if (args == NULL) {
|
if (args == NULL) {
|
||||||
Py_DECREF(func);
|
Py_DECREF(func);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1786,7 +1786,7 @@ instance_ipow(PyObject *v, PyObject *w, PyObject *z)
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
return instance_pow(v, w, z);
|
return instance_pow(v, w, z);
|
||||||
}
|
}
|
||||||
args = Py_BuildValue("(OO)", w, z);
|
args = PyTuple_Pack(2, w, z);
|
||||||
if (args == NULL) {
|
if (args == NULL) {
|
||||||
Py_DECREF(func);
|
Py_DECREF(func);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1859,7 +1859,7 @@ half_richcompare(PyObject *v, PyObject *w, int op)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
args = Py_BuildValue("(O)", w);
|
args = PyTuple_Pack(1, w);
|
||||||
if (args == NULL) {
|
if (args == NULL) {
|
||||||
Py_DECREF(method);
|
Py_DECREF(method);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -439,7 +439,7 @@ complex_divmod(PyComplexObject *v, PyComplexObject *w)
|
||||||
mod = c_diff(v->cval, c_prod(w->cval, div));
|
mod = c_diff(v->cval, c_prod(w->cval, div));
|
||||||
d = PyComplex_FromCComplex(div);
|
d = PyComplex_FromCComplex(div);
|
||||||
m = PyComplex_FromCComplex(mod);
|
m = PyComplex_FromCComplex(mod);
|
||||||
z = Py_BuildValue("(OO)", d, m);
|
z = PyTuple_Pack(2, d, m);
|
||||||
Py_XDECREF(d);
|
Py_XDECREF(d);
|
||||||
Py_XDECREF(m);
|
Py_XDECREF(m);
|
||||||
return z;
|
return z;
|
||||||
|
@ -865,7 +865,7 @@ complex_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
else {
|
else {
|
||||||
PyObject *args = Py_BuildValue("()");
|
PyObject *args = PyTuple_New(0);
|
||||||
if (args == NULL)
|
if (args == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
r = PyEval_CallObject(f, args);
|
r = PyEval_CallObject(f, args);
|
||||||
|
|
|
@ -1227,7 +1227,7 @@ PyFile_GetLine(PyObject *f, int n)
|
||||||
if (reader == NULL)
|
if (reader == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (n <= 0)
|
if (n <= 0)
|
||||||
args = Py_BuildValue("()");
|
args = PyTuple_New(0);
|
||||||
else
|
else
|
||||||
args = Py_BuildValue("(i)", n);
|
args = Py_BuildValue("(i)", n);
|
||||||
if (args == NULL) {
|
if (args == NULL) {
|
||||||
|
@ -2104,7 +2104,7 @@ PyFile_WriteObject(PyObject *v, PyObject *f, int flags)
|
||||||
Py_DECREF(writer);
|
Py_DECREF(writer);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
args = Py_BuildValue("(O)", value);
|
args = PyTuple_Pack(1, value);
|
||||||
if (args == NULL) {
|
if (args == NULL) {
|
||||||
Py_DECREF(value);
|
Py_DECREF(value);
|
||||||
Py_DECREF(writer);
|
Py_DECREF(writer);
|
||||||
|
|
|
@ -163,7 +163,7 @@ mro_subclasses(PyTypeObject *type, PyObject* temp)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PyObject* tuple;
|
PyObject* tuple;
|
||||||
tuple = Py_BuildValue("OO", subclass, old_mro);
|
tuple = PyTuple_Pack(2, subclass, old_mro);
|
||||||
Py_DECREF(old_mro);
|
Py_DECREF(old_mro);
|
||||||
if (!tuple)
|
if (!tuple)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -258,8 +258,8 @@ type_set_bases(PyTypeObject *type, PyObject *value, void *context)
|
||||||
for (i = 0; i < PyList_Size(temp); i++) {
|
for (i = 0; i < PyList_Size(temp); i++) {
|
||||||
PyTypeObject* cls;
|
PyTypeObject* cls;
|
||||||
PyObject* mro;
|
PyObject* mro;
|
||||||
PyArg_ParseTuple(PyList_GET_ITEM(temp, i),
|
PyArg_UnpackTuple(PyList_GET_ITEM(temp, i),
|
||||||
"OO", &cls, &mro);
|
"", 2, 2, &cls, &mro);
|
||||||
Py_DECREF(cls->tp_mro);
|
Py_DECREF(cls->tp_mro);
|
||||||
cls->tp_mro = mro;
|
cls->tp_mro = mro;
|
||||||
Py_INCREF(cls->tp_mro);
|
Py_INCREF(cls->tp_mro);
|
||||||
|
@ -1606,7 +1606,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
|
||||||
|
|
||||||
/* Adjust for empty tuple bases */
|
/* Adjust for empty tuple bases */
|
||||||
if (nbases == 0) {
|
if (nbases == 0) {
|
||||||
bases = Py_BuildValue("(O)", &PyBaseObject_Type);
|
bases = PyTuple_Pack(1, &PyBaseObject_Type);
|
||||||
if (bases == NULL)
|
if (bases == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
nbases = 1;
|
nbases = 1;
|
||||||
|
@ -1650,7 +1650,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
|
||||||
|
|
||||||
/* Make it into a tuple */
|
/* Make it into a tuple */
|
||||||
if (PyString_Check(slots))
|
if (PyString_Check(slots))
|
||||||
slots = Py_BuildValue("(O)", slots);
|
slots = PyTuple_Pack(1, slots);
|
||||||
else
|
else
|
||||||
slots = PySequence_Tuple(slots);
|
slots = PySequence_Tuple(slots);
|
||||||
if (slots == NULL) {
|
if (slots == NULL) {
|
||||||
|
@ -2644,8 +2644,7 @@ reduce_2(PyObject *obj)
|
||||||
PyTuple_SET_ITEM(args2, i+1, v);
|
PyTuple_SET_ITEM(args2, i+1, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
res = Py_BuildValue("(OOOOO)",
|
res = PyTuple_Pack(5, newobj, args2, state, listitems, dictitems);
|
||||||
newobj, args2, state, listitems, dictitems);
|
|
||||||
|
|
||||||
end:
|
end:
|
||||||
Py_XDECREF(cls);
|
Py_XDECREF(cls);
|
||||||
|
@ -3142,7 +3141,7 @@ PyType_Ready(PyTypeObject *type)
|
||||||
if (base == NULL)
|
if (base == NULL)
|
||||||
bases = PyTuple_New(0);
|
bases = PyTuple_New(0);
|
||||||
else
|
else
|
||||||
bases = Py_BuildValue("(O)", base);
|
bases = PyTuple_Pack(1, base);
|
||||||
if (bases == NULL)
|
if (bases == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
type->tp_bases = bases;
|
type->tp_bases = bases;
|
||||||
|
@ -4127,7 +4126,7 @@ slot_sq_contains(PyObject *self, PyObject *value)
|
||||||
|
|
||||||
func = lookup_maybe(self, "__contains__", &contains_str);
|
func = lookup_maybe(self, "__contains__", &contains_str);
|
||||||
if (func != NULL) {
|
if (func != NULL) {
|
||||||
args = Py_BuildValue("(O)", value);
|
args = PyTuple_Pack(1, value);
|
||||||
if (args == NULL)
|
if (args == NULL)
|
||||||
res = NULL;
|
res = NULL;
|
||||||
else {
|
else {
|
||||||
|
@ -4342,7 +4341,7 @@ half_compare(PyObject *self, PyObject *other)
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
args = Py_BuildValue("(O)", other);
|
args = PyTuple_Pack(1, other);
|
||||||
if (args == NULL)
|
if (args == NULL)
|
||||||
res = NULL;
|
res = NULL;
|
||||||
else {
|
else {
|
||||||
|
@ -4571,7 +4570,7 @@ half_richcompare(PyObject *self, PyObject *other, int op)
|
||||||
Py_INCREF(Py_NotImplemented);
|
Py_INCREF(Py_NotImplemented);
|
||||||
return Py_NotImplemented;
|
return Py_NotImplemented;
|
||||||
}
|
}
|
||||||
args = Py_BuildValue("(O)", other);
|
args = PyTuple_Pack(1, other);
|
||||||
if (args == NULL)
|
if (args == NULL)
|
||||||
res = NULL;
|
res = NULL;
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -323,7 +323,7 @@ builtin_coerce(PyObject *self, PyObject *args)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (PyNumber_Coerce(&v, &w) < 0)
|
if (PyNumber_Coerce(&v, &w) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
res = Py_BuildValue("(OO)", v, w);
|
res = PyTuple_Pack(2, v, w);
|
||||||
Py_DECREF(v);
|
Py_DECREF(v);
|
||||||
Py_DECREF(w);
|
Py_DECREF(w);
|
||||||
return res;
|
return res;
|
||||||
|
@ -2185,7 +2185,7 @@ filtertuple(PyObject *func, PyObject *tuple)
|
||||||
good = item;
|
good = item;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PyObject *arg = Py_BuildValue("(O)", item);
|
PyObject *arg = PyTuple_Pack(1, item);
|
||||||
if (arg == NULL) {
|
if (arg == NULL) {
|
||||||
Py_DECREF(item);
|
Py_DECREF(item);
|
||||||
goto Fail_1;
|
goto Fail_1;
|
||||||
|
@ -2252,7 +2252,7 @@ filterstring(PyObject *func, PyObject *strobj)
|
||||||
ok = 1;
|
ok = 1;
|
||||||
} else {
|
} else {
|
||||||
PyObject *arg, *good;
|
PyObject *arg, *good;
|
||||||
arg = Py_BuildValue("(O)", item);
|
arg = PyTuple_Pack(1, item);
|
||||||
if (arg == NULL) {
|
if (arg == NULL) {
|
||||||
Py_DECREF(item);
|
Py_DECREF(item);
|
||||||
goto Fail_1;
|
goto Fail_1;
|
||||||
|
@ -2346,7 +2346,7 @@ filterunicode(PyObject *func, PyObject *strobj)
|
||||||
if (func == Py_None) {
|
if (func == Py_None) {
|
||||||
ok = 1;
|
ok = 1;
|
||||||
} else {
|
} else {
|
||||||
arg = Py_BuildValue("(O)", item);
|
arg = PyTuple_Pack(1, item);
|
||||||
if (arg == NULL) {
|
if (arg == NULL) {
|
||||||
Py_DECREF(item);
|
Py_DECREF(item);
|
||||||
goto Fail_1;
|
goto Fail_1;
|
||||||
|
|
|
@ -1473,7 +1473,7 @@ eval_frame(PyFrameObject *f)
|
||||||
x = NULL;
|
x = NULL;
|
||||||
}
|
}
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
x = Py_BuildValue("(O)", v);
|
x = PyTuple_Pack(1, v);
|
||||||
if (x == NULL)
|
if (x == NULL)
|
||||||
err = -1;
|
err = -1;
|
||||||
}
|
}
|
||||||
|
@ -1981,7 +1981,7 @@ eval_frame(PyFrameObject *f)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
u = TOP();
|
u = TOP();
|
||||||
w = Py_BuildValue("(OOOO)",
|
w = PyTuple_Pack(4,
|
||||||
w,
|
w,
|
||||||
f->f_globals,
|
f->f_globals,
|
||||||
f->f_locals == NULL ?
|
f->f_locals == NULL ?
|
||||||
|
@ -2999,7 +2999,7 @@ call_exc_trace(Py_tracefunc func, PyObject *self, PyFrameObject *f)
|
||||||
value = Py_None;
|
value = Py_None;
|
||||||
Py_INCREF(value);
|
Py_INCREF(value);
|
||||||
}
|
}
|
||||||
arg = Py_BuildValue("(OOO)", type, value, traceback);
|
arg = PyTuple_Pack(3, type, value, traceback);
|
||||||
if (arg == NULL) {
|
if (arg == NULL) {
|
||||||
PyErr_Restore(type, value, traceback);
|
PyErr_Restore(type, value, traceback);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -610,7 +610,7 @@ com_error(struct compiling *c, PyObject *exc, char *msg)
|
||||||
Py_None, line);
|
Py_None, line);
|
||||||
if (t == NULL)
|
if (t == NULL)
|
||||||
goto exit;
|
goto exit;
|
||||||
w = Py_BuildValue("(OO)", v, t);
|
w = PyTuple_Pack(2, v, t);
|
||||||
if (w == NULL)
|
if (w == NULL)
|
||||||
goto exit;
|
goto exit;
|
||||||
PyErr_SetObject(exc, w);
|
PyErr_SetObject(exc, w);
|
||||||
|
@ -969,7 +969,7 @@ com_add(struct compiling *c, PyObject *list, PyObject *dict, PyObject *v)
|
||||||
PyObject *w, *t, *np=NULL;
|
PyObject *w, *t, *np=NULL;
|
||||||
long n;
|
long n;
|
||||||
|
|
||||||
t = Py_BuildValue("(OO)", v, v->ob_type);
|
t = PyTuple_Pack(2, v, v->ob_type);
|
||||||
if (t == NULL)
|
if (t == NULL)
|
||||||
goto fail;
|
goto fail;
|
||||||
w = PyDict_GetItem(dict, t);
|
w = PyDict_GetItem(dict, t);
|
||||||
|
|
|
@ -159,13 +159,13 @@ PyErr_NormalizeException(PyObject **exc, PyObject **val, PyObject **tb)
|
||||||
PyObject *args, *res;
|
PyObject *args, *res;
|
||||||
|
|
||||||
if (value == Py_None)
|
if (value == Py_None)
|
||||||
args = Py_BuildValue("()");
|
args = PyTuple_New(0);
|
||||||
else if (PyTuple_Check(value)) {
|
else if (PyTuple_Check(value)) {
|
||||||
Py_INCREF(value);
|
Py_INCREF(value);
|
||||||
args = value;
|
args = value;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
args = Py_BuildValue("(O)", value);
|
args = PyTuple_Pack(1, value);
|
||||||
|
|
||||||
if (args == NULL)
|
if (args == NULL)
|
||||||
goto finally;
|
goto finally;
|
||||||
|
@ -560,7 +560,7 @@ PyErr_NewException(char *name, PyObject *base, PyObject *dict)
|
||||||
classname = PyString_FromString(dot+1);
|
classname = PyString_FromString(dot+1);
|
||||||
if (classname == NULL)
|
if (classname == NULL)
|
||||||
goto failure;
|
goto failure;
|
||||||
bases = Py_BuildValue("(O)", base);
|
bases = PyTuple_Pack(1, base);
|
||||||
if (bases == NULL)
|
if (bases == NULL)
|
||||||
goto failure;
|
goto failure;
|
||||||
result = PyClass_New(bases, dict, classname);
|
result = PyClass_New(bases, dict, classname);
|
||||||
|
|
|
@ -1821,7 +1821,7 @@ _PyExc_Init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now we need to pre-allocate a MemoryError instance */
|
/* Now we need to pre-allocate a MemoryError instance */
|
||||||
args = Py_BuildValue("()");
|
args = PyTuple_New(0);
|
||||||
if (!args ||
|
if (!args ||
|
||||||
!(PyExc_MemoryErrorInst = PyEval_CallObject(PyExc_MemoryError, args)))
|
!(PyExc_MemoryErrorInst = PyEval_CallObject(PyExc_MemoryError, args)))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1037,7 +1037,7 @@ PyErr_PrintEx(int set_sys_last_vars)
|
||||||
}
|
}
|
||||||
hook = PySys_GetObject("excepthook");
|
hook = PySys_GetObject("excepthook");
|
||||||
if (hook) {
|
if (hook) {
|
||||||
PyObject *args = Py_BuildValue("(OOO)",
|
PyObject *args = PyTuple_Pack(3,
|
||||||
exception, v ? v : Py_None, tb ? tb : Py_None);
|
exception, v ? v : Py_None, tb ? tb : Py_None);
|
||||||
PyObject *result = PyEval_CallObject(hook, args);
|
PyObject *result = PyEval_CallObject(hook, args);
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
|
|
Loading…
Reference in New Issue