-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
PEP 657 added "fine-grained errors" which are similar to executing's AST-level text_range. But the default python traceback printing goes further, employing two types of error markers, ^ and ~. The latter is a "secondary" marker used for further detailed refinement for exceptions involving binary and indexing operators. Example:
File fge.py
x={}; x['a']={}; x['a']['b'] = None
x['a']['b']['c']['d'] = 1Produces:
% python3.12 fge.py
Traceback (most recent call last):
File "/Users/jdsmith/code/python/scraps/fge.py", line 2, in <module>
x['a']['b']['c']['d'] = 1
~~~~~~~~~~~^^^^^
TypeError: 'NoneType' object is not subscriptablewhile executing (here in iPython), shows:
One way to support this secondary refinement in a backwards-compatible way would be with an additional method text_range_secondary that computes the sub-region within text_range (if any) that could be highlighted distinctly.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels