Commit 5cc10b00 authored by Benjamin Peterson's avatar Benjamin Peterson

merge 3.2

parents 1dc54070 f5fcd33b
...@@ -1587,6 +1587,7 @@ order (MRO) for bases """ ...@@ -1587,6 +1587,7 @@ order (MRO) for bases """
("__floor__", math.floor, zero, set(), {}), ("__floor__", math.floor, zero, set(), {}),
("__trunc__", math.trunc, zero, set(), {}), ("__trunc__", math.trunc, zero, set(), {}),
("__ceil__", math.ceil, zero, set(), {}), ("__ceil__", math.ceil, zero, set(), {}),
("__dir__", dir, empty_seq, set(), {}),
] ]
class Checker(object): class Checker(object):
......
...@@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1? ...@@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1?
Core and Builtins 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 - Issue #12060: Use sig_atomic_t type and volatile keyword in the signal
module. Patch written by Charles-François Natali. module. Patch written by Charles-François Natali.
......
...@@ -1364,14 +1364,15 @@ error: ...@@ -1364,14 +1364,15 @@ error:
static PyObject * static PyObject *
_dir_object(PyObject *obj) _dir_object(PyObject *obj)
{ {
PyObject * result = NULL; PyObject *result = NULL;
PyObject * dirfunc = PyObject_GetAttrString((PyObject*)obj->ob_type, static PyObject *dir_str = NULL;
"__dir__"); PyObject *dirfunc = _PyObject_LookupSpecial(obj, "__dir__", &dir_str);
assert(obj); assert(obj);
if (dirfunc == NULL) { if (dirfunc == NULL) {
if (PyErr_Occurred())
return NULL;
/* use default implementation */ /* use default implementation */
PyErr_Clear();
if (PyModule_Check(obj)) if (PyModule_Check(obj))
result = _specialized_dir_module(obj); result = _specialized_dir_module(obj);
else if (PyType_Check(obj)) else if (PyType_Check(obj))
...@@ -1381,7 +1382,7 @@ _dir_object(PyObject *obj) ...@@ -1381,7 +1382,7 @@ _dir_object(PyObject *obj)
} }
else { else {
/* use __dir__ */ /* use __dir__ */
result = PyObject_CallFunctionObjArgs(dirfunc, obj, NULL); result = PyObject_CallFunctionObjArgs(dirfunc, NULL);
Py_DECREF(dirfunc); Py_DECREF(dirfunc);
if (result == NULL) if (result == NULL)
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment