This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author nedbat
Recipients Mark.Shannon, nedbat
Date 2022-01-15.12:26:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1642249582.51.0.604668369809.issue46389@roundup.psfhosted.org>
In-reply-to
Content
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>
History
Date User Action Args
2022-01-15 12:26:22nedbatsetrecipients: + nedbat, Mark.Shannon
2022-01-15 12:26:22nedbatsetmessageid: <1642249582.51.0.604668369809.issue46389@roundup.psfhosted.org>
2022-01-15 12:26:22nedbatlinkissue46389 messages
2022-01-15 12:26:22nedbatcreate