summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-05-23 21:27:36 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-05-23 21:27:36 (GMT)
commit5cc10b00094f06af56dedd02d39bc46886e17c70 (patch)
treea6bb19f9a5eab8dfa7d1145d92b87c3b9faba61d
parent1dc540702072c381c3e7570f075a3f1147353d92 (diff)
parentf5fcd33be9b21b148774d3fa2832bb0627e94809 (diff)
downloadcpython-5cc10b00094f06af56dedd02d39bc46886e17c70.zip
cpython-5cc10b00094f06af56dedd02d39bc46886e17c70.tar.gz
cpython-5cc10b00094f06af56dedd02d39bc46886e17c70.tar.bz2
merge 3.2
-rw-r--r--Lib/test/test_descr.py1
-rw-r--r--Misc/NEWS3
-rw-r--r--Objects/object.c11
3 files changed, 10 insertions, 5 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 9273c46..31731d2 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1587,6 +1587,7 @@ order (MRO) for bases """
("__floor__", math.floor, zero, set(), {}),
("__trunc__", math.trunc, zero, set(), {}),
("__ceil__", math.ceil, zero, set(), {}),
+ ("__dir__", dir, empty_seq, set(), {}),
]
class Checker(object):
diff --git a/Misc/NEWS b/Misc/NEWS
index 01b95e2..22c3cf4 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1?
Core and Builtins
-----------------
+- Correct lookup of __dir__ on objects. Among other things, this causes errors
+ besides AttributeError found on lookup to be propagated.
+
- Issue #12060: Use sig_atomic_t type and volatile keyword in the signal
module. Patch written by Charles-François Natali.
diff --git a/Objects/object.c b/Objects/object.c
index db7882a..d8e2ffb 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1364,14 +1364,15 @@ error:
static PyObject *
_dir_object(PyObject *obj)
{
- PyObject * result = NULL;
- PyObject * dirfunc = PyObject_GetAttrString((PyObject*)obj->ob_type,
- "__dir__");
+ PyObject *result = NULL;
+ 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))
result = _specialized_dir_module(obj);
else if (PyType_Check(obj))
@@ -1381,7 +1382,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;