-
-
Notifications
You must be signed in to change notification settings - Fork 30k
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
IDLE: make use of extended error info. #91312
Comments
In 3.10 and 3.11: >>> while s := input.read(MAXBINSIZE):
... while len(s) < MAXBINSIZE and ns := input.read(MAXBINSIZE-len(s)):
File "<stdin>", line 2
while len(s) < MAXBINSIZE and ns := input.read(MAXBINSIZE-len(s)):
^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: cannot use assignment expressions with expression IDLE only colors the 'l' of 'len'; add extended marking. At least in 3.11, some non-syntax errors have 'fine-grained markings'. x = {'a': {'b': None}}
x['a']['b']['c']['d'] = 1
print(x['a']['b']['c']['d'])
$ python3.11 test.py
Traceback (most recent call last):
File "/data/shared/lusers/enneking/test.py", line 4 in <module>
x['a']['b']['c']['d'] = 1
~~~~~~~~~~~^^^^^
TypeError: 'NoneType' object is not subscriptable Adding colors may require monkeypatching method or subclassing class in traceback.py. May have commented on traceback issue or PR. Or perhaps use sys._excepthook instead of current code and replace ~^ with colors as print. Note that present on each of multiple lines. Would have to decide on how to differentiate ~ context versus ^ error site. Could initially not. Or use color 'diluted' with white or foreground or background or mixture color? (Experiment needed.) Related: Put interactive SyntaxErrors in box. EDIT: Anyone really want a log of error that occurred during a session? Andre Roberge would like the last error accessible |
If by this you mean having access to the error from a known place (like sys.last_traceback or something else specific to IDLE but available from a script), then the answer from me is definitely yes. |
I clarified my question above as meaning a (recording) of all errors in a session included in the shell output that can be saved to a file. This would be a different issue. So would accessibility from a script. I don't remember if Mar 29 is before or after I patched run.py to improve this. |
Has there been any progress made on making use of 3.11's |
co_positions returns an iterable of source-code positions corresponding to bytecodes. I believe it is used, in the standard exception handler, used by the REPL, to created the position-marking lines I illustrated above. This issue is about changing IDLE to retrieve and make use of this newly available information in its simulated Shell. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: