]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-43950: support some multi-line expressions for PEP 657 (GH-27339)
authorBatuhan Taskaya <batuhan@python.org>
Sun, 25 Jul 2021 22:01:44 +0000 (01:01 +0300)
committerGitHub <noreply@github.com>
Sun, 25 Jul 2021 22:01:44 +0000 (15:01 -0700)
commit3e235e0447e373d81f195f4292959c7be9c013dc
tree3fe06bef120b56ff47d75abd70b32db050b7c99b
parent96cf5a63d2dbadaebf236362b4c7c09c51fda55c
bpo-43950: support some multi-line expressions for PEP 657 (GH-27339)

This is basically something that I noticed up while fixing test runs for another issue. It is really common to have multiline calls, and when they fail the display is kind of weird since we omit the annotations. E.g;

```
 $ ./python t.py
Traceback (most recent call last):
  File "/home/isidentical/cpython/cpython/t.py", line 11, in <module>
    frame_1()
    ^^^^^^^^^
  File "/home/isidentical/cpython/cpython/t.py", line 5, in frame_1
    frame_2(
  File "/home/isidentical/cpython/cpython/t.py", line 2, in frame_2
    return a / 0 / b / c
           ~~^~~
ZeroDivisionError: division by zero
```

This patch basically adds support for annotating the rest of the line, if the instruction covers multiple lines (start_line != end_line).

Automerge-Triggered-By: GH:isidentical
Lib/test/test_doctest.py
Lib/test/test_traceback.py
Lib/traceback.py
Python/traceback.c