diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-08-22 21:33:13 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-08-22 21:33:13 (GMT) |
commit | 463b86a881ab9afc4c24f4a669582626977708d7 (patch) | |
tree | cf0434ac97f18bbc29973f9883ce10451f0aaa8d /Objects | |
parent | 155ea65e5c88d250a752ee5321860ef11ede4085 (diff) | |
download | cpython-463b86a881ab9afc4c24f4a669582626977708d7.zip cpython-463b86a881ab9afc4c24f4a669582626977708d7.tar.gz cpython-463b86a881ab9afc4c24f4a669582626977708d7.tar.bz2 |
Issue #27809: Use _PyObject_FastCallDict()
Modify:
* init_subclass()
* builtin___build_class__()
Fix also a bug in init_subclass(): check for super() failure.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/typeobject.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 544d0b5..63bfd66 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -7007,30 +7007,28 @@ set_names(PyTypeObject *type) static int init_subclass(PyTypeObject *type, PyObject *kwds) { - PyObject *super, *func, *tmp, *tuple; + PyObject *super, *func, *result; + PyObject *args[2] = {(PyObject *)type, (PyObject *)type}; + + super = _PyObject_FastCall((PyObject *)&PySuper_Type, args, 2); + if (super == NULL) { + return -1; + } - super = PyObject_CallFunctionObjArgs((PyObject *) &PySuper_Type, - type, type, NULL); func = _PyObject_GetAttrId(super, &PyId___init_subclass__); Py_DECREF(super); - - if (func == NULL) + if (func == NULL) { return -1; - - tuple = PyTuple_New(0); - if (tuple == NULL) { - Py_DECREF(func); - return 0; } - tmp = PyObject_Call(func, tuple, kwds); - Py_DECREF(tuple); - Py_DECREF(func); - if (tmp == NULL) + result = _PyObject_FastCallDict(func, NULL, 0, kwds); + Py_DECREF(func); + if (result == NULL) { return -1; + } - Py_DECREF(tmp); + Py_DECREF(result); return 0; } |