diff options
author | Jeroen Demeyer <J.Demeyer@UGent.be> | 2019-07-04 10:31:34 (GMT) |
---|---|---|
committer | Inada Naoki <songofacandy@gmail.com> | 2019-07-04 10:31:34 (GMT) |
commit | 196a530e00d88a138973bf9182e013937e293f97 (patch) | |
tree | 35443abb5aa148b459f68ae43a18cdbb0627ba76 /Objects | |
parent | 9d40554e0da09a44a8547f3f3a2b9dedfeaf7928 (diff) | |
download | cpython-196a530e00d88a138973bf9182e013937e293f97.zip cpython-196a530e00d88a138973bf9182e013937e293f97.tar.gz cpython-196a530e00d88a138973bf9182e013937e293f97.tar.bz2 |
bpo-37483: add _PyObject_CallOneArg() function (#14558)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/abstract.c | 10 | ||||
-rw-r--r-- | Objects/bytearrayobject.c | 6 | ||||
-rw-r--r-- | Objects/bytesobject.c | 3 | ||||
-rw-r--r-- | Objects/descrobject.c | 5 | ||||
-rw-r--r-- | Objects/dictobject.c | 3 | ||||
-rw-r--r-- | Objects/fileobject.c | 2 | ||||
-rw-r--r-- | Objects/floatobject.c | 2 | ||||
-rw-r--r-- | Objects/genobject.c | 8 | ||||
-rw-r--r-- | Objects/listobject.c | 3 | ||||
-rw-r--r-- | Objects/longobject.c | 3 | ||||
-rw-r--r-- | Objects/memoryobject.c | 4 | ||||
-rw-r--r-- | Objects/moduleobject.c | 3 | ||||
-rw-r--r-- | Objects/typeobject.c | 5 | ||||
-rw-r--r-- | Objects/unicodeobject.c | 10 | ||||
-rw-r--r-- | Objects/weakrefobject.c | 2 |
15 files changed, 29 insertions, 40 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index 77d0914..86178a7 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -172,13 +172,13 @@ PyObject_GetItem(PyObject *o, PyObject *key) } if (PyType_Check(o)) { - PyObject *meth, *result, *stack[1] = {key}; + PyObject *meth, *result; _Py_IDENTIFIER(__class_getitem__); if (_PyObject_LookupAttrId(o, &PyId___class_getitem__, &meth) < 0) { return NULL; } if (meth) { - result = _PyObject_FastCall(meth, stack, 1); + result = _PyObject_CallOneArg(meth, key); Py_DECREF(meth); return result; } @@ -737,7 +737,7 @@ PyObject_Format(PyObject *obj, PyObject *format_spec) } /* And call it. */ - result = PyObject_CallFunctionObjArgs(meth, format_spec, NULL); + result = _PyObject_CallOneArg(meth, format_spec); Py_DECREF(meth); if (result && !PyUnicode_Check(result)) { @@ -2459,7 +2459,7 @@ PyObject_IsInstance(PyObject *inst, PyObject *cls) Py_DECREF(checker); return ok; } - res = PyObject_CallFunctionObjArgs(checker, inst, NULL); + res = _PyObject_CallOneArg(checker, inst); Py_LeaveRecursiveCall(); Py_DECREF(checker); if (res != NULL) { @@ -2533,7 +2533,7 @@ PyObject_IsSubclass(PyObject *derived, PyObject *cls) Py_DECREF(checker); return ok; } - res = PyObject_CallFunctionObjArgs(checker, derived, NULL); + res = _PyObject_CallOneArg(checker, derived); Py_LeaveRecursiveCall(); Py_DECREF(checker); if (res != NULL) { diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index 1bb19a9..9dd6712 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -89,8 +89,7 @@ _canresize(PyByteArrayObject *self) PyObject * PyByteArray_FromObject(PyObject *input) { - return PyObject_CallFunctionObjArgs((PyObject *)&PyByteArray_Type, - input, NULL); + return _PyObject_CallOneArg((PyObject *)&PyByteArray_Type, input); } static PyObject * @@ -2018,8 +2017,7 @@ 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_CallFunctionObjArgs((PyObject *)type, - result, NULL)); + Py_SETREF(result, _PyObject_CallOneArg((PyObject *)type, result)); } return result; } diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index 06c87b0..c4edcca 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -2333,8 +2333,7 @@ bytes_fromhex_impl(PyTypeObject *type, PyObject *string) { PyObject *result = _PyBytes_FromHex(string, 0); if (type != &PyBytes_Type && result != NULL) { - Py_SETREF(result, PyObject_CallFunctionObjArgs((PyObject *)type, - result, NULL)); + Py_SETREF(result, _PyObject_CallOneArg((PyObject *)type, result)); } return result; } diff --git a/Objects/descrobject.c b/Objects/descrobject.c index a0eb505..4b98578 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1340,8 +1340,7 @@ property_descr_get(PyObject *self, PyObject *obj, PyObject *type) return NULL; } - PyObject *args[1] = {obj}; - return _PyObject_FastCall(gs->prop_get, args, 1); + return _PyObject_CallOneArg(gs->prop_get, obj); } static int @@ -1362,7 +1361,7 @@ property_descr_set(PyObject *self, PyObject *obj, PyObject *value) return -1; } if (value == NULL) - res = PyObject_CallFunctionObjArgs(func, obj, NULL); + res = _PyObject_CallOneArg(func, obj); else res = PyObject_CallFunctionObjArgs(func, obj, value, NULL); if (res == NULL) diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 0cc1443..422f4b0 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -2113,8 +2113,7 @@ dict_subscript(PyDictObject *mp, PyObject *key) _Py_IDENTIFIER(__missing__); missing = _PyObject_LookupSpecial((PyObject *)mp, &PyId___missing__); if (missing != NULL) { - res = PyObject_CallFunctionObjArgs(missing, - key, NULL); + res = _PyObject_CallOneArg(missing, key); Py_DECREF(missing); return res; } diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 3791241..a21e490 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -136,7 +136,7 @@ PyFile_WriteObject(PyObject *v, PyObject *f, int flags) Py_DECREF(writer); return -1; } - result = PyObject_CallFunctionObjArgs(writer, value, NULL); + result = _PyObject_CallOneArg(writer, value); Py_DECREF(value); Py_DECREF(writer); if (result == NULL) diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 15cbe5c..689e929 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -1501,7 +1501,7 @@ float_fromhex(PyTypeObject *type, PyObject *string) goto parse_error; result = PyFloat_FromDouble(negate ? -x : x); if (type != &PyFloat_Type && result != NULL) { - Py_SETREF(result, PyObject_CallFunctionObjArgs((PyObject *)type, result, NULL)); + Py_SETREF(result, _PyObject_CallOneArg((PyObject *)type, result)); } return result; diff --git a/Objects/genobject.c b/Objects/genobject.c index 2d9a286..5d1f9c7 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -57,7 +57,7 @@ _PyGen_Finalize(PyObject *self) /* Save the current exception, if any. */ PyErr_Fetch(&error_type, &error_value, &error_traceback); - res = PyObject_CallFunctionObjArgs(finalizer, self, NULL); + res = _PyObject_CallOneArg(finalizer, self); if (res == NULL) { PyErr_WriteUnraisable(self); @@ -562,7 +562,7 @@ _PyGen_SetStopIterationValue(PyObject *value) return 0; } /* Construct an exception instance manually with - * PyObject_CallFunctionObjArgs and pass it to PyErr_SetObject. + * _PyObject_CallOneArg and pass it to PyErr_SetObject. * * We do this to handle a situation when "value" is a tuple, in which * case PyErr_SetObject would set the value of StopIteration to @@ -570,7 +570,7 @@ _PyGen_SetStopIterationValue(PyObject *value) * * (See PyErr_SetObject/_PyErr_CreateException code for details.) */ - e = PyObject_CallFunctionObjArgs(PyExc_StopIteration, value, NULL); + e = _PyObject_CallOneArg(PyExc_StopIteration, value); if (e == NULL) { return -1; } @@ -1279,7 +1279,7 @@ async_gen_init_hooks(PyAsyncGenObject *o) PyObject *res; Py_INCREF(firstiter); - res = PyObject_CallFunctionObjArgs(firstiter, o, NULL); + res = _PyObject_CallOneArg(firstiter, (PyObject *)o); Py_DECREF(firstiter); if (res == NULL) { return 1; diff --git a/Objects/listobject.c b/Objects/listobject.c index f8bf45e..d012ab9 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -2258,8 +2258,7 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse) } for (i = 0; i < saved_ob_size ; i++) { - keys[i] = PyObject_CallFunctionObjArgs(keyfunc, saved_ob_item[i], - NULL); + keys[i] = _PyObject_CallOneArg(keyfunc, saved_ob_item[i]); if (keys[i] == NULL) { for (i=i-1 ; i>=0 ; i--) Py_DECREF(keys[i]); diff --git a/Objects/longobject.c b/Objects/longobject.c index 50ea2a4..3978f5c 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -5611,8 +5611,7 @@ int_from_bytes_impl(PyTypeObject *type, PyObject *bytes_obj, Py_DECREF(bytes); if (long_obj != NULL && type != &PyLong_Type) { - Py_SETREF(long_obj, PyObject_CallFunctionObjArgs((PyObject *)type, - long_obj, NULL)); + Py_SETREF(long_obj, _PyObject_CallOneArg((PyObject *)type, long_obj)); } return long_obj; diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index a873ac1..66920eaf 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -1962,7 +1962,7 @@ struct_get_unpacker(const char *fmt, Py_ssize_t itemsize) if (format == NULL) goto error; - structobj = PyObject_CallFunctionObjArgs(Struct, format, NULL); + structobj = _PyObject_CallOneArg(Struct, format); if (structobj == NULL) goto error; @@ -2001,7 +2001,7 @@ struct_unpack_single(const char *ptr, struct unpacker *x) PyObject *v; memcpy(x->item, ptr, x->itemsize); - v = PyObject_CallFunctionObjArgs(x->unpack_from, x->mview, NULL); + v = _PyObject_CallOneArg(x->unpack_from, x->mview); if (v == NULL) return NULL; diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c index 85134c7..92f97e6 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -736,8 +736,7 @@ module_getattro(PyModuleObject *m, PyObject *name) _Py_IDENTIFIER(__getattr__); getattr = _PyDict_GetItemId(m->md_dict, &PyId___getattr__); if (getattr) { - PyObject* stack[1] = {name}; - return _PyObject_FastCall(getattr, stack, 1); + return _PyObject_CallOneArg(getattr, name); } _Py_IDENTIFIER(__name__); mod_name = _PyDict_GetItemId(m->md_dict, &PyId___name__); diff --git a/Objects/typeobject.c b/Objects/typeobject.c index f814333..3b9a537 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1459,8 +1459,7 @@ static PyObject* call_unbound_noarg(int unbound, PyObject *func, PyObject *self) { if (unbound) { - PyObject *args[1] = {self}; - return _PyObject_FastCall(func, args, 1); + return _PyObject_CallOneArg(func, self); } else { return _PyObject_CallNoArg(func); @@ -6561,7 +6560,7 @@ call_attribute(PyObject *self, PyObject *attr, PyObject *name) else attr = descr; } - res = PyObject_CallFunctionObjArgs(attr, name, NULL); + res = _PyObject_CallOneArg(attr, name); Py_XDECREF(descr); return res; } diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 51d314b..5545eae 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -4248,7 +4248,7 @@ unicode_decode_call_errorhandler_wchar( if (*exceptionObject == NULL) goto onError; - restuple = PyObject_CallFunctionObjArgs(*errorHandler, *exceptionObject, NULL); + restuple = _PyObject_CallOneArg(*errorHandler, *exceptionObject); if (restuple == NULL) goto onError; if (!PyTuple_Check(restuple)) { @@ -4352,7 +4352,7 @@ unicode_decode_call_errorhandler_writer( if (*exceptionObject == NULL) goto onError; - restuple = PyObject_CallFunctionObjArgs(*errorHandler, *exceptionObject, NULL); + restuple = _PyObject_CallOneArg(*errorHandler, *exceptionObject); if (restuple == NULL) goto onError; if (!PyTuple_Check(restuple)) { @@ -6799,8 +6799,7 @@ unicode_encode_call_errorhandler(const char *errors, if (*exceptionObject == NULL) return NULL; - restuple = PyObject_CallFunctionObjArgs( - *errorHandler, *exceptionObject, NULL); + restuple = _PyObject_CallOneArg(*errorHandler, *exceptionObject); if (restuple == NULL) return NULL; if (!PyTuple_Check(restuple)) { @@ -8778,8 +8777,7 @@ unicode_translate_call_errorhandler(const char *errors, if (*exceptionObject == NULL) return NULL; - restuple = PyObject_CallFunctionObjArgs( - *errorHandler, *exceptionObject, NULL); + restuple = _PyObject_CallOneArg(*errorHandler, *exceptionObject); if (restuple == NULL) return NULL; if (!PyTuple_Check(restuple)) { diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c index 8b8e710..ae3f6dc 100644 --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -874,7 +874,7 @@ PyWeakref_GetObject(PyObject *ref) static void handle_callback(PyWeakReference *ref, PyObject *callback) { - PyObject *cbresult = PyObject_CallFunctionObjArgs(callback, ref, NULL); + PyObject *cbresult = _PyObject_CallOneArg(callback, (PyObject *)ref); if (cbresult == NULL) PyErr_WriteUnraisable(callback); |