mirror of
https://github.com/python/cpython.git
synced 2026-01-08 08:22:41 +00:00
merge 3.1
This commit is contained in:
commit
f5fcd33be9
3 changed files with 10 additions and 5 deletions
|
|
@ -1587,6 +1587,7 @@ def format_impl(self, spec):
|
|||
("__floor__", math.floor, zero, set(), {}),
|
||||
("__trunc__", math.trunc, zero, set(), {}),
|
||||
("__ceil__", math.ceil, zero, set(), {}),
|
||||
("__dir__", dir, empty_seq, set(), {}),
|
||||
]
|
||||
|
||||
class Checker(object):
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ Core and Builtins
|
|||
Library
|
||||
-------
|
||||
|
||||
- Correct lookup of __dir__ on objects. Among other things, this causes errors
|
||||
besides AttributeError found on lookup to be propagated.
|
||||
|
||||
- Issue #12124: zipimport doesn't keep a reference to zlib.decompress() anymore
|
||||
to be able to unload the module.
|
||||
|
||||
|
|
|
|||
|
|
@ -1366,14 +1366,15 @@ _generic_dir(PyObject *obj)
|
|||
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))
|
||||
|
|
@ -1383,7 +1384,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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue