[New-bugs-announce] [issue45563] inspect.getframeinfo() doesn't handle frames without lineno

Marc-Andre Lemburg report at bugs.python.org
Thu Oct 21 18:02:12 EDT 2021


New submission from Marc-Andre Lemburg <mal at egenix.com>:

In Python 3.10, it seems that top-level frames generated by running exec() have their f_lineno attribute set to None.

inspect.getframeinfo() tries to build context lines and fails on this line in such a case:

        start = lineno - 1 - context//2

because lineno is None.

It's not clear whether this is a bug in inspect or the way such frames get their f_lineno attribute initialized.

The same code works just fine in Python 3.9.

----------
messages: 404674
nosy: lemburg
priority: normal
severity: normal
status: open
title: inspect.getframeinfo() doesn't handle frames without lineno
versions: Python 3.10

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


More information about the New-bugs-announce mailing list