summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-09-10 18:27:43 (GMT)
committerGuido van Rossum <guido@python.org>2001-09-10 18:27:43 (GMT)
commit8dbd3d8c50e4f4c96f2466ad18ca33b2af4fe240 (patch)
tree2aadc1e42a917785d86d21538dd10184dd697e81 /Objects
parentb8755093109692d1708b87268c80a65b473e798e (diff)
downloadcpython-8dbd3d8c50e4f4c96f2466ad18ca33b2af4fe240.zip
cpython-8dbd3d8c50e4f4c96f2466ad18ca33b2af4fe240.tar.gz
cpython-8dbd3d8c50e4f4c96f2466ad18ca33b2af4fe240.tar.bz2
PyObject_Dir():
- 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.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/object.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 365d131..704ffc1 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -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.