mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Backed out changeset b9c9691c72c5
Issue #28858: The change b9c9691c72c5 introduced a regression. It seems like _PyObject_CallArg1() uses more stack memory than PyObject_CallFunctionObjArgs().
This commit is contained in:
parent
c8d03187ff
commit
de4ae3d486
33 changed files with 83 additions and 71 deletions
|
@ -103,7 +103,7 @@ PyObject_LengthHint(PyObject *o, Py_ssize_t defaultvalue)
|
|||
}
|
||||
return defaultvalue;
|
||||
}
|
||||
result = _PyObject_CallNoArg(hint);
|
||||
result = PyObject_CallFunctionObjArgs(hint, NULL);
|
||||
Py_DECREF(hint);
|
||||
if (result == NULL) {
|
||||
if (PyErr_ExceptionMatches(PyExc_TypeError)) {
|
||||
|
@ -716,7 +716,7 @@ PyObject_Format(PyObject *obj, PyObject *format_spec)
|
|||
}
|
||||
|
||||
/* And call it. */
|
||||
result = _PyObject_CallArg1(meth, format_spec);
|
||||
result = PyObject_CallFunctionObjArgs(meth, format_spec, NULL);
|
||||
Py_DECREF(meth);
|
||||
|
||||
if (result && !PyUnicode_Check(result)) {
|
||||
|
@ -3011,7 +3011,7 @@ PyObject_IsInstance(PyObject *inst, PyObject *cls)
|
|||
Py_DECREF(checker);
|
||||
return ok;
|
||||
}
|
||||
res = _PyObject_CallArg1(checker, inst);
|
||||
res = PyObject_CallFunctionObjArgs(checker, inst, NULL);
|
||||
Py_LeaveRecursiveCall();
|
||||
Py_DECREF(checker);
|
||||
if (res != NULL) {
|
||||
|
@ -3085,7 +3085,7 @@ PyObject_IsSubclass(PyObject *derived, PyObject *cls)
|
|||
Py_DECREF(checker);
|
||||
return ok;
|
||||
}
|
||||
res = _PyObject_CallArg1(checker, derived);
|
||||
res = PyObject_CallFunctionObjArgs(checker, derived, NULL);
|
||||
Py_LeaveRecursiveCall();
|
||||
Py_DECREF(checker);
|
||||
if (res != NULL) {
|
||||
|
|
|
@ -98,7 +98,8 @@ _canresize(PyByteArrayObject *self)
|
|||
PyObject *
|
||||
PyByteArray_FromObject(PyObject *input)
|
||||
{
|
||||
return _PyObject_CallArg1((PyObject *)&PyByteArray_Type, input);
|
||||
return PyObject_CallFunctionObjArgs((PyObject *)&PyByteArray_Type,
|
||||
input, NULL);
|
||||
}
|
||||
|
||||
PyObject *
|
||||
|
@ -1984,7 +1985,8 @@ bytearray_fromhex_impl(PyTypeObject *type, PyObject *string)
|
|||
{
|
||||
PyObject *result = _PyBytes_FromHex(string, type == &PyByteArray_Type);
|
||||
if (type != &PyByteArray_Type && result != NULL) {
|
||||
Py_SETREF(result, _PyObject_CallArg1((PyObject *)type, result));
|
||||
Py_SETREF(result, PyObject_CallFunctionObjArgs((PyObject *)type,
|
||||
result, NULL));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -549,7 +549,7 @@ format_obj(PyObject *v, const char **pbuf, Py_ssize_t *plen)
|
|||
/* does it support __bytes__? */
|
||||
func = _PyObject_LookupSpecial(v, &PyId___bytes__);
|
||||
if (func != NULL) {
|
||||
result = _PyObject_CallNoArg(func);
|
||||
result = PyObject_CallFunctionObjArgs(func, NULL);
|
||||
Py_DECREF(func);
|
||||
if (result == NULL)
|
||||
return NULL;
|
||||
|
@ -2331,7 +2331,8 @@ bytes_fromhex_impl(PyTypeObject *type, PyObject *string)
|
|||
{
|
||||
PyObject *result = _PyBytes_FromHex(string, 0);
|
||||
if (type != &PyBytes_Type && result != NULL) {
|
||||
Py_SETREF(result, _PyObject_CallArg1((PyObject *)type, result));
|
||||
Py_SETREF(result, PyObject_CallFunctionObjArgs((PyObject *)type,
|
||||
result, NULL));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -2568,7 +2569,7 @@ bytes_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
PyObject_Bytes doesn't do. */
|
||||
func = _PyObject_LookupSpecial(x, &PyId___bytes__);
|
||||
if (func != NULL) {
|
||||
new = _PyObject_CallNoArg(func);
|
||||
new = PyObject_CallFunctionObjArgs(func, NULL);
|
||||
Py_DECREF(func);
|
||||
if (new == NULL)
|
||||
return NULL;
|
||||
|
|
|
@ -273,7 +273,7 @@ try_complex_special_method(PyObject *op) {
|
|||
|
||||
f = _PyObject_LookupSpecial(op, &PyId___complex__);
|
||||
if (f) {
|
||||
PyObject *res = _PyObject_CallNoArg(f);
|
||||
PyObject *res = PyObject_CallFunctionObjArgs(f, NULL);
|
||||
Py_DECREF(f);
|
||||
if (res != NULL && !PyComplex_Check(res)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
|
|
|
@ -1414,7 +1414,7 @@ property_descr_set(PyObject *self, PyObject *obj, PyObject *value)
|
|||
return -1;
|
||||
}
|
||||
if (value == NULL)
|
||||
res = _PyObject_CallArg1(func, obj);
|
||||
res = PyObject_CallFunctionObjArgs(func, obj, NULL);
|
||||
else
|
||||
res = PyObject_CallFunctionObjArgs(func, obj, value, NULL);
|
||||
if (res == NULL)
|
||||
|
|
|
@ -2066,7 +2066,8 @@ dict_subscript(PyDictObject *mp, PyObject *key)
|
|||
_Py_IDENTIFIER(__missing__);
|
||||
missing = _PyObject_LookupSpecial((PyObject *)mp, &PyId___missing__);
|
||||
if (missing != NULL) {
|
||||
res = _PyObject_CallArg1(missing, key);
|
||||
res = PyObject_CallFunctionObjArgs(missing,
|
||||
key, NULL);
|
||||
Py_DECREF(missing);
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -258,7 +258,7 @@ reversed_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
return NULL;
|
||||
}
|
||||
if (reversed_meth != NULL) {
|
||||
PyObject *res = _PyObject_CallNoArg(reversed_meth);
|
||||
PyObject *res = PyObject_CallFunctionObjArgs(reversed_meth, NULL);
|
||||
Py_DECREF(reversed_meth);
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -1439,7 +1439,7 @@ float_fromhex(PyObject *cls, PyObject *arg)
|
|||
goto parse_error;
|
||||
result = PyFloat_FromDouble(negate ? -x : x);
|
||||
if (cls != (PyObject *)&PyFloat_Type && result != NULL) {
|
||||
Py_SETREF(result, _PyObject_CallArg1(cls, result));
|
||||
Py_SETREF(result, PyObject_CallFunctionObjArgs(cls, result, NULL));
|
||||
}
|
||||
return result;
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ _PyGen_Finalize(PyObject *self)
|
|||
/* Save the current exception, if any. */
|
||||
PyErr_Fetch(&error_type, &error_value, &error_traceback);
|
||||
|
||||
res = _PyObject_CallArg1(finalizer, self);
|
||||
res = PyObject_CallFunctionObjArgs(finalizer, self, NULL);
|
||||
|
||||
if (res == NULL) {
|
||||
PyErr_WriteUnraisable(self);
|
||||
|
@ -591,7 +591,7 @@ _PyGen_SetStopIterationValue(PyObject *value)
|
|||
*
|
||||
* (See PyErr_SetObject/_PyErr_CreateException code for details.)
|
||||
*/
|
||||
e = _PyObject_CallArg1(PyExc_StopIteration, value);
|
||||
e = PyObject_CallFunctionObjArgs(PyExc_StopIteration, value, NULL);
|
||||
if (e == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -1970,7 +1970,8 @@ listsort(PyListObject *self, PyObject *args, PyObject *kwds)
|
|||
}
|
||||
|
||||
for (i = 0; i < saved_ob_size ; i++) {
|
||||
keys[i] = _PyObject_CallArg1(keyfunc, saved_ob_item[i]);
|
||||
keys[i] = PyObject_CallFunctionObjArgs(keyfunc, saved_ob_item[i],
|
||||
NULL);
|
||||
if (keys[i] == NULL) {
|
||||
for (i=i-1 ; i>=0 ; i--)
|
||||
Py_DECREF(keys[i]);
|
||||
|
|
|
@ -5282,7 +5282,8 @@ long_from_bytes(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
Py_DECREF(bytes);
|
||||
|
||||
if (type != &PyLong_Type) {
|
||||
Py_SETREF(long_obj, _PyObject_CallArg1((PyObject *)type, long_obj));
|
||||
Py_SETREF(long_obj, PyObject_CallFunctionObjArgs((PyObject *)type,
|
||||
long_obj, NULL));
|
||||
}
|
||||
|
||||
return long_obj;
|
||||
|
|
|
@ -1939,7 +1939,7 @@ struct_get_unpacker(const char *fmt, Py_ssize_t itemsize)
|
|||
if (format == NULL)
|
||||
goto error;
|
||||
|
||||
structobj = _PyObject_CallArg1(Struct, format);
|
||||
structobj = PyObject_CallFunctionObjArgs(Struct, format, NULL);
|
||||
if (structobj == NULL)
|
||||
goto error;
|
||||
|
||||
|
@ -1978,7 +1978,7 @@ struct_unpack_single(const char *ptr, struct unpacker *x)
|
|||
PyObject *v;
|
||||
|
||||
memcpy(x->item, ptr, x->itemsize);
|
||||
v = _PyObject_CallArg1(x->unpack_from, x->mview);
|
||||
v = PyObject_CallFunctionObjArgs(x->unpack_from, x->mview, NULL);
|
||||
if (v == NULL)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -596,7 +596,7 @@ PyObject_Bytes(PyObject *v)
|
|||
|
||||
func = _PyObject_LookupSpecial(v, &PyId___bytes__);
|
||||
if (func != NULL) {
|
||||
result = _PyObject_CallNoArg(func);
|
||||
result = PyObject_CallFunctionObjArgs(func, NULL);
|
||||
Py_DECREF(func);
|
||||
if (result == NULL)
|
||||
return NULL;
|
||||
|
@ -1314,7 +1314,7 @@ _dir_object(PyObject *obj)
|
|||
return NULL;
|
||||
}
|
||||
/* use __dir__ */
|
||||
result = _PyObject_CallNoArg(dirfunc);
|
||||
result = PyObject_CallFunctionObjArgs(dirfunc, NULL);
|
||||
Py_DECREF(dirfunc);
|
||||
if (result == NULL)
|
||||
return NULL;
|
||||
|
|
|
@ -1256,7 +1256,7 @@ odict_copy(register PyODictObject *od)
|
|||
if (PyODict_CheckExact(od))
|
||||
od_copy = PyODict_New();
|
||||
else
|
||||
od_copy = _PyObject_CallNoArg((PyObject *)Py_TYPE(od));
|
||||
od_copy = PyObject_CallFunctionObjArgs((PyObject *)Py_TYPE(od), NULL);
|
||||
if (od_copy == NULL)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -3487,7 +3487,9 @@ object_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
sorted = _PyDict_GetItemId(builtins, &PyId_sorted);
|
||||
if (sorted == NULL)
|
||||
goto error;
|
||||
sorted_methods = _PyObject_CallArg1(sorted, abstract_methods);
|
||||
sorted_methods = PyObject_CallFunctionObjArgs(sorted,
|
||||
abstract_methods,
|
||||
NULL);
|
||||
if (sorted_methods == NULL)
|
||||
goto error;
|
||||
comma = _PyUnicode_FromId(&comma_id);
|
||||
|
@ -6191,7 +6193,7 @@ call_attribute(PyObject *self, PyObject *attr, PyObject *name)
|
|||
else
|
||||
attr = descr;
|
||||
}
|
||||
res = _PyObject_CallArg1(attr, name);
|
||||
res = PyObject_CallFunctionObjArgs(attr, name, NULL);
|
||||
Py_XDECREF(descr);
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -4269,7 +4269,7 @@ unicode_decode_call_errorhandler_wchar(
|
|||
if (*exceptionObject == NULL)
|
||||
goto onError;
|
||||
|
||||
restuple = _PyObject_CallArg1(*errorHandler, *exceptionObject);
|
||||
restuple = PyObject_CallFunctionObjArgs(*errorHandler, *exceptionObject, NULL);
|
||||
if (restuple == NULL)
|
||||
goto onError;
|
||||
if (!PyTuple_Check(restuple)) {
|
||||
|
@ -4368,7 +4368,7 @@ unicode_decode_call_errorhandler_writer(
|
|||
if (*exceptionObject == NULL)
|
||||
goto onError;
|
||||
|
||||
restuple = _PyObject_CallArg1(*errorHandler, *exceptionObject);
|
||||
restuple = PyObject_CallFunctionObjArgs(*errorHandler, *exceptionObject, NULL);
|
||||
if (restuple == NULL)
|
||||
goto onError;
|
||||
if (!PyTuple_Check(restuple)) {
|
||||
|
@ -6649,7 +6649,8 @@ unicode_encode_call_errorhandler(const char *errors,
|
|||
if (*exceptionObject == NULL)
|
||||
return NULL;
|
||||
|
||||
restuple = _PyObject_CallArg1(*errorHandler, *exceptionObject);
|
||||
restuple = PyObject_CallFunctionObjArgs(
|
||||
*errorHandler, *exceptionObject, NULL);
|
||||
if (restuple == NULL)
|
||||
return NULL;
|
||||
if (!PyTuple_Check(restuple)) {
|
||||
|
@ -8643,7 +8644,8 @@ unicode_translate_call_errorhandler(const char *errors,
|
|||
if (*exceptionObject == NULL)
|
||||
return NULL;
|
||||
|
||||
restuple = _PyObject_CallArg1(*errorHandler, *exceptionObject);
|
||||
restuple = PyObject_CallFunctionObjArgs(
|
||||
*errorHandler, *exceptionObject, NULL);
|
||||
if (restuple == NULL)
|
||||
return NULL;
|
||||
if (!PyTuple_Check(restuple)) {
|
||||
|
|
|
@ -867,7 +867,7 @@ PyWeakref_GetObject(PyObject *ref)
|
|||
static void
|
||||
handle_callback(PyWeakReference *ref, PyObject *callback)
|
||||
{
|
||||
PyObject *cbresult = _PyObject_CallArg1(callback, ref);
|
||||
PyObject *cbresult = PyObject_CallFunctionObjArgs(callback, ref, NULL);
|
||||
|
||||
if (cbresult == NULL)
|
||||
PyErr_WriteUnraisable(callback);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue