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 ValueError in HyperParser #88329
Comments
Here's a new error that I hadn't seen before. I occurred at some point during a full day training session, so am not sure what triggered the failure: Exception in Tkinter callback
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 1892, in __call__
return self.func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/idlelib/multicall.py", line 176, in handler
r = l[i](event)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/idlelib/calltip.py", line 51, in try_open_calltip_event
self.open_calltip(False)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/idlelib/calltip.py", line 62, in open_calltip
hp = HyperParser(self.editwin, "insert")
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/idlelib/hyperparser.py", line 79, in __init__
self.set_index(index)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/idlelib/hyperparser.py", line 89, in set_index
raise ValueError("Index %s precedes the analyzed statement"
ValueError: Index insert precedes the analyzed statement |
Thank you for the report. Which 3.9.? hyperparser has not changed in a year, but some of the calltip logic has. This occurred when you typed a '(' and IDLE tried to open a calltip but failed, and you did not notice its absence. Easy when not looking for it to help complete the call, especially when others are around. Do you have any idea if more likely to have been in editor or shell, or did you use a mix of both? The preceding lines are indexinrawtext = (len(self.rawtext) -
len(self.text.get(index, self.stopatindex)))
if indexinrawtext < 0: The resolution of this issue might be augment the error message to print the window type, the index as line.col as well as 'insert', the two lengths, and at least part of the text. We should perhaps look at other callback error messages that IDLE raises. |
I constantly move back and forth between the editor and the shell, so am not sure where the issue occurred. Also, I've never seen this one before so it isn't easily triggered. Am running Python 3.9.5 in class. Am not using a special build, it is the macOS build found on python.org. |
So, consider both possibilities where relevant. In the future, I will assume that you are running standard, up-to-date, Mac build unless you say otherwise. I presume you start IDLE from terminal and check it before shutting down. I have wondered whether it might be worthwhile to try to catch the occasional messages even when running from an icon. Seems it might be. This conditional exception was part of the 2005 merge of the separate IDLE branch. So there is no history to say whether 'just-in-case' or known trigger. |
I took a look but can't see any obvious bugs there. ISTM that's a rather harmless edge case. I can't think of anything to do with this except to close for now, and reopen if this pops up again. Thinking a few steps forward, to make sense of such issues, it would be greatly beneficial to get a full stack dump rather than just a traceback. Perhaps we should add something of the sort to IDLE, ideally something which works even when not running from the command line? |
For now, I want to just improve the error message and then close. |
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: