-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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 with -1 line number #88463
Comments
While debugging https://bugs.python.org/issue43921 on Windows, I got a traceback with a single frame and the frame line number is -1. It looks like a Python 3.11 regression. Mark, Guido: can it be related to recent optimization work done in the main branch? See also bpo-44288 "unittest: _is_relevant_tb_level() fails because tb.tb_frame.f_globals=None". ====================================================================== During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\vstinner\python\main\lib\test\test_ssl.py", line -1, in test_pha_required_nocert
AssertionError: "certificate required" does not match "EOF occurred in violation of protocol (_ssl.c:2522)" |
Is this a re-regression of https://bugs.python.org/issue43933? |
this appears to have regressed in 3.10 as well according to some reports on pytest: pytest-dev/pytest#8227 (comment) |
here's the traceback pytest is trying to display and crashing:
|
here is a minimal reproduction: def iterboom():
raise AssertionError
yield 1
next(1 for x in iterboom()) python 3.9:
|
Thanks Anthony, that's a big help. |
Can the issue be closed? I'm not sure which assertion failed in test_ssl.test_pha_required_nocert(). I bet on this one:
I don't know if the commit 82e5c28 is supported is to fix issue or not. |
Oh, I can still reproduce the issue on the main branch with this patch: diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index cee97a8302..3f66818ae1 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -4499,7 +4499,7 @@ def msg_cb(conn, direction, version, content_type, msg_type, data):
# server aborts connection with an error.
with self.assertRaisesRegex(
ssl.SSLError,
- '(certificate required|EOF occurred)'
+ 'xxxxxxxxxxxxx'
):
# receive CertificateRequest
data = s.recv(1024) $ ./python -m test test_ssl -m test_pha_required_nocert -v
(...)
FAIL: test_pha_required_nocert (test.test_ssl.TestPostHandshakeAuth) (...)
Traceback (most recent call last):
File "/home/vstinner/python/main/Lib/test/test_ssl.py", line -1, in test_pha_required_nocert
AssertionError: (...)
... => "line -1" |
Here presumably the error is occurring somewhere near unittest. I've tested this and wrote a minimal reproducible example.
Running this with Hope this helps. |
Oh it is also occurring when running from script (I ran it from IDLE and it always results in correct lineno). I wrote example similar to how unittests work and the frame with -1 lineno is also occurring there. Here is the code -
Also, unsurprisingly, pdb fails with a "TypeError: '>=' not supported between instances of 'NoneType' and 'int'". Full pdb log - Traceback (most recent call last):
File "C:\Users\shrey\Desktop\line_negative_one.py", line -1, in <module>
File "C:\github\cpython\lib\bdb.py", line 96, in trace_dispatch
return self.dispatch_exception(frame, arg)
File "C:\github\cpython\lib\bdb.py", line 169, in dispatch_exception
if self.stop_here(frame):
File "C:\github\cpython\lib\bdb.py", line 212, in stop_here
return frame.f_lineno >= self.stoplineno
TypeError: '>=' not supported between instances of 'NoneType' and 'int' |
Thanks for the reproducer. |
Found the culprit - Line 5268 in 769d7d0
Same goes for async with - Line 5171 in 769d7d0
(Didn't test async with so I can be wrong there.) Is this intentional? I removed these lines and the line number is coming correct. Can changing this affect other use cases? Without the change: Traceback (most recent call last):
File "C:\Users\shrey\Desktop\line_negative_one.py", line 8, in <module>
raise Exception("Normal Error")
Exception: Normal Error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\shrey\Desktop\line_negative_one.py", line -1, in <module>
File "C:\Users\shrey\Desktop\line_negative_one.py", line 5, in __exit__
raise Exception("Frame is -1 if program is run from command line")
Exception: Frame is -1 if program is run from command line With the change: Traceback (most recent call last):
File "C:\Users\shrey\Desktop\line_negative_one.py", line 8, in <module>
raise Exception("Normal Error")
Exception: Normal Error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\shrey\Desktop\line_negative_one.py", line 7, in <module>
with A():
File "C:\Users\shrey\Desktop\line_negative_one.py", line 5, in __exit__
raise Exception("Frame is -1 if program is run from command line")
Exception: Frame is not -1 anymore if program is run from command line |
I believe this to be fixed. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: