Skip to content
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

Open
rhettinger opened this issue May 17, 2021 · 6 comments
Open

IDLE ValueError in HyperParser #88329

rhettinger opened this issue May 17, 2021 · 6 comments
Assignees
Labels
3.9 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error

Comments

@rhettinger
Copy link
Contributor

BPO 44163
Nosy @rhettinger, @terryjreedy, @taleinat

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:

assignee = 'https://github.com/terryjreedy'
closed_at = None
created_at = <Date 2021-05-17.23:47:23.018>
labels = ['expert-IDLE', 'type-bug', '3.9']
title = 'IDLE ValueError in HyperParser'
updated_at = <Date 2021-05-20.21:47:07.374>
user = 'https://github.com/rhettinger'

bugs.python.org fields:

activity = <Date 2021-05-20.21:47:07.374>
actor = 'terry.reedy'
assignee = 'terry.reedy'
closed = False
closed_date = None
closer = None
components = ['IDLE']
creation = <Date 2021-05-17.23:47:23.018>
creator = 'rhettinger'
dependencies = []
files = []
hgrepos = []
issue_num = 44163
keywords = []
message_count = 6.0
messages = ['393845', '393851', '393987', '394001', '394006', '394072']
nosy_count = 3.0
nosy_names = ['rhettinger', 'terry.reedy', 'taleinat']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue44163'
versions = ['Python 3.9']

@rhettinger
Copy link
Contributor Author

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

@rhettinger rhettinger added the 3.9 only security fixes label May 17, 2021
@rhettinger rhettinger added topic-IDLE type-bug An unexpected behavior, bug, or error 3.9 only security fixes labels May 17, 2021
@rhettinger rhettinger added topic-IDLE type-bug An unexpected behavior, bug, or error labels May 17, 2021
@terryjreedy
Copy link
Member

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.

@rhettinger
Copy link
Contributor Author

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.

@terryjreedy
Copy link
Member

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.

@taleinat
Copy link
Contributor

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?

@terryjreedy
Copy link
Member

For now, I want to just improve the error message and then close.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.9 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error
Projects
Status: No status
Development

No branches or pull requests

3 participants