This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: IDLE ValueError in HyperParser
Type: behavior Stage:
Components: IDLE Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: rhettinger, taleinat, terry.reedy
Priority: normal Keywords:

Created on 2021-05-17 23:47 by rhettinger, last changed 2022-04-11 14:59 by admin.

Messages (6)
msg393845 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-05-17 23:47
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
msg393851 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-05-18 02:33
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.
msg393987 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-05-19 23:59
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.
msg394001 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-05-20 04:21
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.
msg394006 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2021-05-20 08:32
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?
msg394072 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-05-20 21:47
For now, I want to just improve the error message and then close.
History
Date User Action Args
2022-04-11 14:59:45adminsetgithub: 88329
2021-05-20 21:47:07terry.reedysetmessages: + msg394072
2021-05-20 08:32:46taleinatsetmessages: + msg394006
2021-05-20 04:21:42terry.reedysetmessages: + msg394001
2021-05-19 23:59:28rhettingersetmessages: + msg393987
2021-05-18 02:33:12terry.reedysetnosy: + taleinat
messages: + msg393851
2021-05-17 23:47:23rhettingercreate