]> granicus.if.org Git - python/commitdiff
PyObject_Dir():
authorGuido van Rossum <guido@python.org>
Mon, 10 Sep 2001 18:27:43 +0000 (18:27 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 10 Sep 2001 18:27:43 +0000 (18:27 +0000)
  - use PyModule_Check() instead of PyObject_TypeCheck(), now we can.
  - don't assert that the __dict__ gotten out of a module is always
    a dictionary; check its type, and raise an exception if it's not.

Objects/object.c

index 365d1313f7966e3469caba99eba4b651581b2e60..704ffc13b284b5b1050d1cadde323762210732ec 100644 (file)
@@ -1424,11 +1424,15 @@ PyObject_Dir(PyObject *arg)
        }
 
        /* Elif this is some form of module, we only want its dict. */
-       else if (PyObject_TypeCheck(arg, &PyModule_Type)) {
+       else if (PyModule_Check(arg)) {
                masterdict = PyObject_GetAttrString(arg, "__dict__");
                if (masterdict == NULL)
                        goto error;
-               assert(PyDict_Check(masterdict));
+               if (!PyDict_Check(masterdict)) {
+                       PyErr_SetString(PyExc_TypeError,
+                                       "module.__dict__ is not a dictionary");
+                       goto error;
+               }
        }
 
        /* Elif some form of type or class, grab its dict and its bases.