New submission from Marc-Andre Lemburg <m...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue45563>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to