gh-122728: Fix SystemError in PyEval_GetLocals() (#122735)
Fix PyEval_GetLocals() to avoid SystemError ("bad argument to
internal function"). Don't redefine the 'ret' variable in the if
block.
Add an unit test on PyEval_GetLocals().
This commit is contained in:
@@ -2499,7 +2499,7 @@ PyEval_GetLocals(void)
|
||||
PyFrameObject *f = _PyFrame_GetFrameObject(current_frame);
|
||||
PyObject *ret = f->f_locals_cache;
|
||||
if (ret == NULL) {
|
||||
PyObject *ret = PyDict_New();
|
||||
ret = PyDict_New();
|
||||
if (ret == NULL) {
|
||||
Py_DECREF(locals);
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user