mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
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:
parent
5b8a6c5186
commit
4767a6e31c
4 changed files with 23 additions and 1 deletions
|
@ -1157,6 +1157,19 @@ class CAPITest(unittest.TestCase):
|
|||
gen = genf()
|
||||
self.assertEqual(_testcapi.gen_get_code(gen), gen.gi_code)
|
||||
|
||||
def test_pyeval_getlocals(self):
|
||||
# Test PyEval_GetLocals()
|
||||
x = 1
|
||||
self.assertEqual(_testcapi.pyeval_getlocals(),
|
||||
{'self': self,
|
||||
'x': 1})
|
||||
|
||||
y = 2
|
||||
self.assertEqual(_testcapi.pyeval_getlocals(),
|
||||
{'self': self,
|
||||
'x': 1,
|
||||
'y': 2})
|
||||
|
||||
|
||||
@requires_limited_api
|
||||
class TestHeapTypeRelative(unittest.TestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue