summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-05-23 21:11:05 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-05-23 21:11:05 (GMT)
commit8de87a640339165ad5448f468f98fce7819fe99d (patch)
tree03cb2758a0ace65fc9d527ed567a40cbdcaa3c14 /Objects
parent4ef33dc381607937ac9e0a5984a1ec22f238c6ed (diff)
downloadcpython-8de87a640339165ad5448f468f98fce7819fe99d.zip
cpython-8de87a640339165ad5448f468f98fce7819fe99d.tar.gz
cpython-8de87a640339165ad5448f468f98fce7819fe99d.tar.bz2
correctly lookup __dir__
Diffstat (limited to 'Objects')
-rw-r--r--Objects/object.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Objects/object.c b/Objects/object.c
index b6ad5de..1e033d2 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1905,11 +1905,13 @@ static PyObject *
_dir_object(PyObject *obj)
{
PyObject *result = NULL;
- PyObject *dirfunc = PyObject_GetAttrString((PyObject *)obj->ob_type,
- "__dir__");
+ static PyObject *dir_str = NULL;
+ PyObject *dirfunc = _PyObject_LookupSpecial(obj, "__dir__", &dir_str);
assert(obj);
if (dirfunc == NULL) {
+ if (PyErr_Occurred())
+ return NULL;
/* use default implementation */
PyErr_Clear();
if (PyModule_Check(obj))
@@ -1921,7 +1923,7 @@ _dir_object(PyObject *obj)
}
else {
/* use __dir__ */
- result = PyObject_CallFunctionObjArgs(dirfunc, obj, NULL);
+ result = PyObject_CallFunctionObjArgs(dirfunc, NULL);
Py_DECREF(dirfunc);
if (result == NULL)
return NULL;