diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-08-06 21:37:10 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-06 21:37:10 (GMT) |
commit | 5c161cb8329c941aa219dc34c56afa368516d6fb (patch) | |
tree | 819abfe98db80b0e0f776c05e8211adac5e6319e /Lib/test/test_capi/test_misc.py | |
parent | e808146af1841abc7d5f86470041d3ef7712050e (diff) | |
download | cpython-5c161cb8329c941aa219dc34c56afa368516d6fb.zip cpython-5c161cb8329c941aa219dc34c56afa368516d6fb.tar.gz cpython-5c161cb8329c941aa219dc34c56afa368516d6fb.tar.bz2 |
[3.13] gh-122728: Fix SystemError in PyEval_GetLocals() (GH-122735) (#122757)
gh-122728: Fix SystemError in PyEval_GetLocals() (GH-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().
(cherry picked from commit 4767a6e31c0550836b2af45d27e374e721f0c4e6)
Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Lib/test/test_capi/test_misc.py')
-rw-r--r-- | Lib/test/test_capi/test_misc.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_capi/test_misc.py b/Lib/test/test_capi/test_misc.py index f3d16e4..080b3e6 100644 --- a/Lib/test/test_capi/test_misc.py +++ b/Lib/test/test_capi/test_misc.py @@ -1180,6 +1180,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): |