Commit fafad514 authored by Guido van Rossum's avatar Guido van Rossum

The recent changes to super(), in particular supercheck(), broke when

using super() for an instance in a metaclass situation.  Because the
class was a metaclass, the instance was a class, and hence the
PyType_Check() branch was taken.  But this branch didn't apply.  Make
it so that if this branch doesn't apply, the other branch is still
tried.  All tests pass.
parent 9d4abdba
...@@ -5170,16 +5170,14 @@ supercheck(PyTypeObject *type, PyObject *obj) ...@@ -5170,16 +5170,14 @@ supercheck(PyTypeObject *type, PyObject *obj)
This will allow using super() with a proxy for obj. This will allow using super() with a proxy for obj.
*/ */
if (PyType_Check(obj)) { /* Check for first bullet above (special case) */
/* It's a new-style class */ if (PyType_Check(obj) && PyType_IsSubtype((PyTypeObject *)obj, type)) {
if (PyType_IsSubtype((PyTypeObject *)obj, type)) {
Py_INCREF(obj); Py_INCREF(obj);
return (PyTypeObject *)obj; return (PyTypeObject *)obj;
} }
else
goto fail; /* Normal case */
} if (PyType_IsSubtype(obj->ob_type, type)) {
else if (PyType_IsSubtype(obj->ob_type, type)) {
Py_INCREF(obj->ob_type); Py_INCREF(obj->ob_type);
return obj->ob_type; return obj->ob_type;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment