New submission from Ned Batchelder <n...@nedbatchelder.com>:
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> ---------- components: Interpreter Core keywords: 3.11regression messages: 410643 nosy: Mark.Shannon, nedbat priority: normal severity: normal status: open title: 3.11: unused generator comprehensions cause f_lineno==None versions: Python 3.11 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46389> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com