6
6
Batuhan Taskaya <
[email protected] >,
7
7
8
8
Discussions-To: https://discuss.python.org/t/pep-657-include-fine-grained-error-locations-in-tracebacks/8629
9
- Status: Accepted
9
+ Status: Final
10
10
Type: Standards Track
11
11
Content-Type: text/x-rst
12
12
Created: 08-May-2021
@@ -56,7 +56,7 @@ as line numbers, it could helpfully display::
56
56
Traceback (most recent call last):
57
57
File "test.py", line 2, in <module>
58
58
x['a']['b']['c']['d'] = 1
59
- ^^^^^^^^^^^ ^^^^^
59
+ ~~~~~~~~~~~ ^^^^^
60
60
TypeError: 'NoneType' object is not subscriptable
61
61
62
62
indicating to the user that the object ``x['a']['b'] `` must have been ``None ``.
@@ -76,7 +76,7 @@ display the code associated to the current instruction in every frame::
76
76
^^^^^^
77
77
File "test.py", line 6, in lel
78
78
return 1 + foo(a,b,c=x['z']['x']['y']['z']['y'], d=e)
79
- ^^^^^^^^^^^^^^^^ ^^^^^
79
+ ~~~~~~~~~~~~~~~~ ^^^^^
80
80
TypeError: 'NoneType' object is not subscriptable
81
81
82
82
This problem presents itself in the following situations.
@@ -114,7 +114,7 @@ This problem presents itself in the following situations.
114
114
Traceback (most recent call last):
115
115
File "test.py", line 1, in <module>
116
116
x = (a + b) @ (c + d)
117
- ^^^^^
117
+ ~~^~~
118
118
ValueError: operands could not be broadcast together with shapes (1,2) (2,3)
119
119
120
120
Giving a much clearer and easier to debug error message.
@@ -240,7 +240,7 @@ available. For instance::
240
240
241
241
File "test.py", line 6, in lel
242
242
return 1 + foo(a,b,c=x['z']['x']['y']['z']['y'], d=e)
243
- ^^^^^^^^^^^^^^^^ ^^^^^
243
+ ~~~~~~~~~~~~~~~~ ^^^^^
244
244
TypeError: 'NoneType' object is not subscriptable
245
245
246
246
When displaying tracebacks, instruction offsets will be taken from the
@@ -267,7 +267,7 @@ The printed traceback would look like this::
267
267
^^^^^^
268
268
File "test.py", line 2, in foo
269
269
1 + 1/0 + 2
270
- ^^^
270
+ ~^~
271
271
ZeroDivisionError: division by zero
272
272
273
273
The above exception was the direct cause of the following exception:
@@ -303,7 +303,7 @@ Will be displayed as::
303
303
^^^^^^
304
304
File "test.py", line 2, in foo
305
305
1 + 1/0 + 2
306
- ^^^
306
+ ~^~
307
307
ZeroDivisionError: division by zero
308
308
309
309
Maintaining the current behavior, only a single line will be displayed
0 commit comments