-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
frame.f_lineno can be None #94485
Comments
The line number is meaningless when calling a module during an import. If you change def tracefunc(frame, event, arg):
if frame.f_lineno is None and event != "call":
raise AssertionError('frame.f_lineno is None!', frame)
return tracefunc No assertion should be raised. |
We might be able to set the line number to 0, https://peps.python.org/pep-0626/#the-f-lineno-attribute, without producing a line event. |
It is possible in unusual circumstances, such as when the cycle GC invokes Python or a keyboard interrupt, but it shouldn't happen in normal code execution. |
This seems a bit surprising for me... I went on looking for docs but there's surprisingly few information about this (my use case is that I was typing things with cython and it's breaking due to being Given that the first valid line number is |
Moving this back to release blocker. |
…cified by PEP 626 (GH-94552) Co-authored-by: Mark Shannon <mark@hotpy.org>
… to 0, as specified by PEP 626 (pythonGH-94552) Co-authored-by: Mark Shannon <mark@hotpy.org> (cherry picked from commit 324d019) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Main and 3.11 branch are now fixed. Thank you @iritkatriel for the fix and @ambv for the backport. |
Workaround f_lineno being None in some edge cases in some python 3.10 versions. Apparently this only affects module imports, which are traced as calls: python/cpython#94485
Bug report
As far as I know
frame.f_lineno
should never beNone
, yet, in the case below it is:Your environment
3.11.0b3 (main, Jun 1 2022, 13:29:14) [MSC v.1932 64 bit (AMD64)]
Windows
The text was updated successfully, but these errors were encountered: