Message410643
In Python 3.11, unused generator comprehensions cause trace events with f_lineno set to None.
---- %< -------------------------------------------------
import linecache, sys
def trace(frame, event, arg):
# The weird globals here is to avoid a NameError on shutdown...
if frame.f_code.co_filename == globals().get("__file__"):
lineno = frame.f_lineno
if lineno is not None:
line = linecache.getline(__file__, lineno).rstrip()
else:
line = "<none>"
print("{} {!s:4}: {}".format(event[:4], lineno, line))
return trace
print(sys.version)
sys.settrace(trace)
(i for i in [1])
------------------------------------------------------
$ python3.10 /tmp/runbpo.py
3.10.2 (main, Jan 15 2022, 05:51:59) [Clang 12.0.0 (clang-1200.0.32.29)]
call 17 : (i for i in [1])
exce 17 : (i for i in [1])
retu 17 : (i for i in [1])
$ python3.11 /tmp/runbpo.py
3.11.0a4 (main, Jan 14 2022, 18:14:29) [Clang 12.0.0 (clang-1200.0.32.29)]
call None: <none>
exce None: <none>
retu None: <none> |
|
Date |
User |
Action |
Args |
2022-01-15 12:26:22 | nedbat | set | recipients:
+ nedbat, Mark.Shannon |
2022-01-15 12:26:22 | nedbat | set | messageid: <1642249582.51.0.604668369809.issue46389@roundup.psfhosted.org> |
2022-01-15 12:26:22 | nedbat | link | issue46389 messages |
2022-01-15 12:26:22 | nedbat | create | |
|