[issue46389] 3.11: unused generator comprehensions cause f_lineno==None

Stefan Behnel report at bugs.python.org
Fri Feb 25 04:09:16 EST 2022


Stefan Behnel <stefan_ml at behnel.de> added the comment:

Possibly also related, so I though I'd mention it here (sorry if this is hijacking the ticket, seems difficult to tell). We're also seeing None values in f_lineno in Cython's test suite with 3.11a5:

      File "<doctest line_trace.run_trace[2]>", line 1, in <module>
        run_trace(py_add, 1, 2)
        ^^^^^^^^^^^^^^^^^^^^^^^
      File "tests/run/line_trace.pyx", line 231, in line_trace.run_trace (line_trace.c:7000)
        func(*args)
      File "tests/run/line_trace.pyx", line 60, in line_trace.trace_trampoline (line_trace.c:3460)
        raise
      File "tests/run/line_trace.pyx", line 54, in line_trace.trace_trampoline (line_trace.c:3359)
        result = callback(frame, what, arg)
      File "tests/run/line_trace.pyx", line 81, in line_trace._create_trace_func._trace_func (line_trace.c:3927)
        trace.append((map_trace_types(event, event), frame.f_lineno - frame.f_code.co_firstlineno))
    TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'

https://github.com/cython/cython/blob/7ab11ec473a604792bae454305adece55cd8ab37/tests/run/line_trace.pyx

No generator expressions involved, though. (Much of that test was written while trying to get the debugger in PyCharm to work with Cython compiled modules.)

There is a chance that Cython is doing something wrong in its own line tracing code, obviously.
(I also remember seeing other tracing issues before, where the line reported was actually in the trace function itself rather than the code to be traced. We haven't caught up with the frame-internal changes yet.)

----------
nosy: +scoder

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46389>
_______________________________________


More information about the Python-bugs-list mailing list