You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Wrong error location in traceback inside an assert #116034
The location in the traceback for this failed assertion:
test=3asserttest==1andtest==2, "Bug found?"
Seems to be wrong. It should show test == 1 as the source of the error:
Traceback (most recent call last):
File "/home/.../test.py", line 3, in <module>assert test ==1and test ==2, "Bug found?"^^^^^^^^^AssertionError: Bug found?
Hello!
Thanks for the report!
Traceback for current 3.11 branch:
Traceback (most recent call last):
File "/Users/admin/Projects/cpython/example.py", line 2, in <module>assert test ==1and test ==2, "Bug found?"^^^^^^^^^AssertionError: Bug found?
Traceback for current 3.12 branch:
Traceback (most recent call last):
File "/Users/admin/Projects/cpython/example.py", line 2, in <module>assert test ==1and test ==2, "Bug found?"AssertionError: Bug found?
Traceback for current main branch:
Traceback (most recent call last):
File "/Users/admin/Projects/cpython/example.py", line 2, in <module>assert test ==1and test ==2, "Bug found?"^^^^^^^^^^^^^^^^^^^^^^^AssertionError: Bug found?
>>> assert test == 1 and test == 2, "Bug found?"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>assert test ==1and test ==2, "Bug found?"^^^^^^^^^^^^^^^^^^^^^^^AssertionError: Bug found?
Activity
Eclips4 commentedon Feb 28, 2024
Hello!
Thanks for the report!
Traceback for current 3.11 branch:
Traceback for current 3.12 branch:
Traceback for current main branch:
cc @pablogsal
pablogsal commentedon Feb 28, 2024
Error locations are set by the compiler so this is likely a compiler bug. CC @iritkatriel
iritkatriel commentedon Feb 28, 2024
in 3.13 it does this:
pablogsal commentedon Feb 28, 2024
Shouldn't this be just one or the other?
iritkatriel commentedon Feb 28, 2024
Since the line numbers are calculated statically, that would require emitting a different RAISE instruction for each clause. Currently we don't.
pablogsal commentedon Feb 28, 2024
Then it seems there isn't much we can do for 3.13, no? For 3.12 it seems that we don't emit line info
iritkatriel commentedon Feb 28, 2024
For 3.13 we could emit more instructions per assert, if we decide the tradeoff is worth it.
I'm looking at 3.11 / 3.12 and will see if there is an easy fix.
pythongh-116034: fix location info on the error of a failed assertion
pythongh-116034: fix location info on the error of a failed assertion
Rename 2024-02-28-15-38-49.bpo-116034.-Uu9tf.rst to 2024-02-28-15-38-49.
[3.11] gh-116034: fix location info on the error of a failed assertion (
[3.12] gh-116034: fix location info on the error of a failed assertion (
iritkatriel commentedon Feb 29, 2024
I fixed 3.11 and 3.12 to behave like 3.13. I will close this issue as the problem it reports it resolved.
I'm not sure narrowing the ranges is worth more code. If it ever comes up as an actual problem, we can revisit.
Thank you @solanav .
solanav commentedon Feb 29, 2024
Thank you all so much!
tests: Fix compatibility issue with Python 3.13 in vlog.at.
tests: Fix compatibility issue with Python 3.13 in vlog.at.
tests: Fix compatibility issue with Python 3.13 in vlog.at.
tests: Fix compatibility issue with Python 3.13 in vlog.at.
tests: Fix compatibility issue with Python 3.13 in vlog.at.
tests: Fix compatibility issue with Python 3.13 in vlog.at.
tests: Fix compatibility issue with Python 3.13 in vlog.at.
tests: Fix compatibility issue with Python 3.13 in vlog.at.
tests: Fix compatibility issue with Python 3.13 in vlog.at.