mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
[3.13] gh-130070: Fix exec(<string>, closure=<non-None>)
unexpected path (GH-130071) (#132627)
gh-130070: Fix `exec(<string>, closure=<non-None>)` unexpected path (#130071)
Fixed an assertion error (so, it could be reproduced only in builds with assertions enabled)
for `exec` when the `source` argument is a string and the `closure` argument is not `None`.
Co-authored-by: sobolevn <mail@sobolevn.me>
(cherry picked from commit 954b2cf031
)
This commit is contained in:
parent
db7ad1c89f
commit
582d1ef463
3 changed files with 18 additions and 0 deletions
|
@ -974,8 +974,24 @@ class BuiltinTest(unittest.TestCase):
|
|||
three_freevars.__code__,
|
||||
three_freevars.__globals__,
|
||||
closure=my_closure)
|
||||
my_closure = tuple(my_closure)
|
||||
|
||||
# should fail: anything passed to closure= isn't allowed
|
||||
# when the source is a string
|
||||
self.assertRaises(TypeError,
|
||||
exec,
|
||||
"pass",
|
||||
closure=int)
|
||||
|
||||
# should fail: correct closure= argument isn't allowed
|
||||
# when the source is a string
|
||||
self.assertRaises(TypeError,
|
||||
exec,
|
||||
"pass",
|
||||
closure=my_closure)
|
||||
|
||||
# should fail: closure tuple with one non-cell-var
|
||||
my_closure = list(my_closure)
|
||||
my_closure[0] = int
|
||||
my_closure = tuple(my_closure)
|
||||
self.assertRaises(TypeError,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue