summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2003-02-18 19:22:22 (GMT)
committerGuido van Rossum <guido@python.org>2003-02-18 19:22:22 (GMT)
commit8e80a72be402c926250471d7d8d84414629c683f (patch)
treefe5884264509b8e78ff17755cc1a2cbf31d22838 /Objects
parent6b29c0147b964e6afa6a09bb8d694bafc30cf7ad (diff)
downloadcpython-8e80a72be402c926250471d7d8d84414629c683f.zip
cpython-8e80a72be402c926250471d7d8d84414629c683f.tar.gz
cpython-8e80a72be402c926250471d7d8d84414629c683f.tar.bz2
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.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index eb2e08f..52a98bc 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -5170,16 +5170,14 @@ supercheck(PyTypeObject *type, PyObject *obj)
This will allow using super() with a proxy for obj.
*/
- if (PyType_Check(obj)) {
- /* It's a new-style class */
- if (PyType_IsSubtype((PyTypeObject *)obj, type)) {
- Py_INCREF(obj);
- return (PyTypeObject *)obj;
- }
- else
- goto fail;
+ /* Check for first bullet above (special case) */
+ if (PyType_Check(obj) && PyType_IsSubtype((PyTypeObject *)obj, type)) {
+ Py_INCREF(obj);
+ return (PyTypeObject *)obj;
}
- else if (PyType_IsSubtype(obj->ob_type, type)) {
+
+ /* Normal case */
+ if (PyType_IsSubtype(obj->ob_type, type)) {
Py_INCREF(obj->ob_type);
return obj->ob_type;
}