-
-
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
Wrong error location in traceback inside an assert #116034
Comments
Hello! Traceback (most recent call last):
File "/Users/admin/Projects/cpython/example.py", line 2, in <module>
assert test == 1 and 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 == 1 and 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 == 1 and test == 2, "Bug found?"
^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Bug found? cc @pablogsal |
Error locations are set by the compiler so this is likely a compiler bug. CC @iritkatriel |
in 3.13 it does this: >>> assert test == 1 and test == 2, "Bug found?"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
assert test == 1 and test == 2, "Bug found?"
^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Bug found? |
Shouldn't this be just one or the other? |
Since the line numbers are calculated statically, that would require emitting a different RAISE instruction for each clause. Currently we don't. |
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 |
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. |
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 . |
Thank you all so much! |
The vlog - Python3 test makes use of output from Python Tracebacks in its test assertion. In Python 3.13 a line with tophat (``^``) markers is added below Tracebacks from calls to assert [0], which makes the test fail. This change of behavior is also backported to the Python 3.12 and 3.11 stable branches [1]. Strip lines containing one or more occurence of the ``^`` character from the output before performing the test assertions. 0: python/cpython#105935 1: python/cpython#116034 Reported-at: https://launchpad.net/bugs/2060434 Signed-off-by: Frode Nordahl <[email protected]>
The vlog - Python3 test makes use of output from Python Tracebacks in its test assertion. In Python 3.13 a line with tophat (``^``) markers is added below Tracebacks from calls to assert [0], which makes the test fail. This change of behavior is also backported to the Python 3.12 and 3.11 stable branches [1]. Strip lines containing one or more occurence of the ``^`` character from the output before performing the test assertions. 0: python/cpython#105935 1: python/cpython#116034 Reported-at: https://launchpad.net/bugs/2060434 Signed-off-by: Frode Nordahl <[email protected]> Signed-off-by: 0-day Robot <[email protected]>
The vlog - Python3 test makes use of output from Python Tracebacks in its test assertion. In Python 3.13 a line with tophat (``^``) markers is added below Tracebacks from calls to assert [0], which makes the test fail. This change of behavior is also backported to the Python 3.12 and 3.11 stable branches [1]. Strip lines containing one or more occurrence of the ``^`` character from the output before performing the test assertions. 0: python/cpython#105935 1: python/cpython#116034 Reported-at: https://launchpad.net/bugs/2060434 Signed-off-by: Frode Nordahl <[email protected]> Signed-off-by: Ilya Maximets <[email protected]>
The vlog - Python3 test makes use of output from Python Tracebacks in its test assertion. In Python 3.13 a line with tophat (``^``) markers is added below Tracebacks from calls to assert [0], which makes the test fail. This change of behavior is also backported to the Python 3.12 and 3.11 stable branches [1]. Strip lines containing one or more occurrence of the ``^`` character from the output before performing the test assertions. 0: python/cpython#105935 1: python/cpython#116034 Reported-at: https://launchpad.net/bugs/2060434 Signed-off-by: Frode Nordahl <[email protected]> Signed-off-by: Ilya Maximets <[email protected]>
The vlog - Python3 test makes use of output from Python Tracebacks in its test assertion. In Python 3.13 a line with tophat (``^``) markers is added below Tracebacks from calls to assert [0], which makes the test fail. This change of behavior is also backported to the Python 3.12 and 3.11 stable branches [1]. Strip lines containing one or more occurrence of the ``^`` character from the output before performing the test assertions. 0: python/cpython#105935 1: python/cpython#116034 Reported-at: https://launchpad.net/bugs/2060434 Signed-off-by: Frode Nordahl <[email protected]> Signed-off-by: Ilya Maximets <[email protected]>
The vlog - Python3 test makes use of output from Python Tracebacks in its test assertion. In Python 3.13 a line with tophat (``^``) markers is added below Tracebacks from calls to assert [0], which makes the test fail. This change of behavior is also backported to the Python 3.12 and 3.11 stable branches [1]. Strip lines containing one or more occurrence of the ``^`` character from the output before performing the test assertions. 0: python/cpython#105935 1: python/cpython#116034 Reported-at: https://launchpad.net/bugs/2060434 Signed-off-by: Frode Nordahl <[email protected]> Signed-off-by: Ilya Maximets <[email protected]>
The vlog - Python3 test makes use of output from Python Tracebacks in its test assertion. In Python 3.13 a line with tophat (``^``) markers is added below Tracebacks from calls to assert [0], which makes the test fail. This change of behavior is also backported to the Python 3.12 and 3.11 stable branches [1]. Strip lines containing one or more occurrence of the ``^`` character from the output before performing the test assertions. 0: python/cpython#105935 1: python/cpython#116034 Reported-at: https://launchpad.net/bugs/2060434 Signed-off-by: Frode Nordahl <[email protected]> Signed-off-by: Ilya Maximets <[email protected]>
The vlog - Python3 test makes use of output from Python Tracebacks in its test assertion. In Python 3.13 a line with tophat (``^``) markers is added below Tracebacks from calls to assert [0], which makes the test fail. This change of behavior is also backported to the Python 3.12 and 3.11 stable branches [1]. Strip lines containing one or more occurrence of the ``^`` character from the output before performing the test assertions. 0: python/cpython#105935 1: python/cpython#116034 Reported-at: https://launchpad.net/bugs/2060434 Signed-off-by: Frode Nordahl <[email protected]> Signed-off-by: Ilya Maximets <[email protected]>
The vlog - Python3 test makes use of output from Python Tracebacks in its test assertion. In Python 3.13 a line with tophat (``^``) markers is added below Tracebacks from calls to assert [0], which makes the test fail. This change of behavior is also backported to the Python 3.12 and 3.11 stable branches [1]. Strip lines containing one or more occurrence of the ``^`` character from the output before performing the test assertions. 0: python/cpython#105935 1: python/cpython#116034 Reported-at: https://launchpad.net/bugs/2060434 Signed-off-by: Frode Nordahl <[email protected]> Signed-off-by: Ilya Maximets <[email protected]>
Bug report
Bug description:
The location in the traceback for this failed assertion:
Seems to be wrong. It should show
test == 1
as the source of the error:CPython versions tested on:
3.11
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: