Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
Bug description:
Seems to be a regression in 3.12 when compared to 3.11, likely caused byPEP 709: Comprehension inlining, but I haven't verified this. Example below. (Noticed while runningthis code.)
importsysdeff():_= [sysforsysin []]# can be any module other than sys [sys.stdout.write('success\n')for_in [1]]f()
$ python3.11 main.py # 3.11.9success$ python3.12 main.py # 3.12.3Traceback (most recent call last): File "/home/jkozera/imp/main.py", line 5, in <module> f() File "/home/jkozera/imp/main.py", line 4, in f [sys.stdout.write('success\n') for _ in [1]] ^^^UnboundLocalError: cannot access local variable 'sys' where it is not associated with a value$ python3.13 main.py # 3.13.0a6+ (heads/main:2770d5c, May 2 2024, 18:19:03)Traceback (most recent call last): File "/home/jkozera/imp/main.py", line 5, in <module> f() ~^^ File "/home/jkozera/imp/main.py", line 4, in f [sys.stdout.write('success\n') for _ in [1]] ^^^UnboundLocalError: cannot access local variable 'sys' where it is not associated with a valueCPython versions tested on:
3.11, 3.12, CPython main branch
Operating systems tested on:
Linux