merge 3.2

This commit is contained in:
Benjamin Peterson 2011-05-23 16:27:36 -05:00
commit 5cc10b0009
3 changed files with 10 additions and 5 deletions

View file

@ -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;