[issue44446] linecache.getline TypeError when formatting tracebacks in stacks containing an async list comprehension

Filipe Laíns report at bugs.python.org
Thu Jun 17 20:03:13 EDT 2021


Filipe Laíns <lains at riseup.net> added the comment:

Upon further investigation, there are actually two issues here. The first would be the one I identified already, traceback.FrameSummary not being prepared for lineno being None, but there is also a regression in lineno being invalid in this situation in the first place.

With only GH-26781, the traceback will look like the following:


  File "/home/anubis/git/cpython/rep.py", line 13, in <module>
    next(bar().__await__(), None)
  File "/home/anubis/git/cpython/rep.py", line 10, in bar
    return [chunk async for chunk in foo()]
  File "/home/anubis/git/cpython/rep.py", line None, in <listcomp>
  File "/home/anubis/git/cpython/rep.py", line 6, in foo
    traceback.print_stack()
working!


which is different from 3.9



  File "/home/anubis/git/cpython/rep.py", line 13, in <module>
    next(bar().__await__(), None)
  File "/home/anubis/git/cpython/rep.py", line 10, in bar
    return [chunk async for chunk in foo()]
  File "/home/anubis/git/cpython/rep.py", line 10, in <listcomp>
    return [chunk async for chunk in foo()]
  File "/home/anubis/git/cpython/rep.py", line 6, in foo
    traceback.print_stack()
working!


I bisected the second issue to b37181e69209746adc2119c471599a1ea5faa6c8 which moves generators to bytecode, and when doing so changes the behavior to set lineno to -1. I have opened a GH-26782 to fixing this.

----------

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


More information about the Python-bugs-list mailing list