mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
gh-105340: include hidden fast-locals in locals() (#105715)
* gh-105340: include hidden fast-locals in locals()
This commit is contained in:
parent
838406b4fc
commit
104d7b760f
8 changed files with 160 additions and 44 deletions
|
|
@ -1690,13 +1690,15 @@ _dir_locals(void)
|
|||
PyObject *names;
|
||||
PyObject *locals;
|
||||
|
||||
locals = PyEval_GetLocals();
|
||||
locals = _PyEval_GetFrameLocals();
|
||||
if (locals == NULL)
|
||||
return NULL;
|
||||
|
||||
names = PyMapping_Keys(locals);
|
||||
if (!names)
|
||||
Py_DECREF(locals);
|
||||
if (!names) {
|
||||
return NULL;
|
||||
}
|
||||
if (!PyList_Check(names)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"dir(): expected keys() of locals to be a list, "
|
||||
|
|
@ -1708,7 +1710,6 @@ _dir_locals(void)
|
|||
Py_DECREF(names);
|
||||
return NULL;
|
||||
}
|
||||
/* the locals don't need to be DECREF'd */
|
||||
return names;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue