[REQUEST] PEP657 error code ranges in tracebacks
See original GitHub issuePython 3.11 implements code position ranges in tracebacks.
from rich.traceback import install
install(show_locals=True)
data = [
{
"person": {
"friends": [
{"name": "Sally",
"age": 32},
{"name": "Yuri",
"age": 43}
],
"location": "Warsaw, Poland"
}
}
]
print(data[0]["person"]["friends"][2]["name"])
The default exception handler will print the position of the offending error in the traceback:
Traceback (most recent call last):
File "/Users/anthonyshaw/projects/python-3.11-demos/error_messages.py", line 15, in <module>
print(data[0]["person"]["friends"][2]["name"])
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range
Rich does not use this data (but still looks very pretty)
IT would be great to get the trace messages with arrows.
Issue Analytics
- State:
- Created a year ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
PEP 657 – Include Fine Grained Error Locations in Tracebacks
In order to identify the range of source code being executed when exceptions are raised, this proposal requires adding new data for every ......
Read more >HTTP response status codes - MDN Web Docs - Mozilla
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes:
Read more >Python 3.11: Cool New Features for You to Try - Real Python
More Informative Error Tracebacks; Faster Code Execution; Nicer Syntax for ... python inverse.py Traceback (most recent call last): File ...
Read more >What's New In Python 3.11 — Python 3.9.9 documentation
Traceback (most recent call last): File "distance.py", line 11, ... sqlite3 exceptions now include the SQLite extended error code as sqlite_errorcode and ...
Read more >What's New In Python 3.11-BeJSON.com
Traceback (most recent call last): File "query.py", line 37, in <module> ... extended PEP 657 position information (end line number, column and end...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is very much a drive-by comment: I wonder if there’s Unicode characters that could be used for this.
Note: TracebackException now has the
offset
andend_offset
attributes which expose the information needed to print the arrows.https://github.com/python/cpython/blob/3.11/Lib/traceback.py#L852-L864