diff Objects/typeobject.c @ 65047:340d1bf5951e

type.__abstractmethods__ should raise an AttributeError #10006
author Benjamin Peterson <benjamin@python.org>
date Sat, 02 Oct 2010 00:03:31 +0000
parents 2e5bde383a5c
children dec08789a9b4
line wrap: on
line diff
--- a/Objects/typeobject.c	Fri Oct 01 23:42:24 2010 +0000
+++ b/Objects/typeobject.c	Sat Oct 02 00:03:31 2010 +0000
@@ -320,8 +320,11 @@
 static PyObject *
 type_abstractmethods(PyTypeObject *type, void *context)
 {
-    PyObject *mod = PyDict_GetItemString(type->tp_dict,
-                                         "__abstractmethods__");
+    PyObject *mod = NULL;
+    /* type its self has an __abstractmethods__ descriptor (this). Don't
+       return that. */
+    if (type != &PyType_Type)
+        mod = PyDict_GetItemString(type->tp_dict, "__abstractmethods__");
     if (!mod) {
         PyErr_Format(PyExc_AttributeError, "__abstractmethods__");
         return NULL;