-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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: Shell calltips bugged by printed unclosed "(''' " #105689
Comments
The first bug, which is not an IDLE issue, is the regression of help() crashing upon invalid names. It should catch the exception and print stuff, including a new help prompt, as it used to do. #105702. The issue here is whether IDLE could be made immune to this or whether something like inspect, which IDLE uses, is messed up. So I will try to find out where the wrong tip is coming from. |
It seems to me that the first issue only appeared in 3.11 or so. Before that, it would say:
and continue. |
The discussion of the help bug is on the issue I opened and the issue it duplicated, #102541. There was a related issue just before 3.11.0 was released. The wrong message line
Among whatever else this call does, it makes the line the doc string of ImportError. Since ImportError has no accessible signature, the line is the calltip for ImportError. For some reason I will investigate another day, calltip.getargspec(ob) is being called with ob == ImportError, not with the function the user types. |
But why does that also affect every other object's calltip (like |
Also, I've found another bug.
Apparently, only some inputs will restore it back to its original value. Trying |
Because IDLE is displaying the calltip for ImportError regardless of what is typed. I am looking into this now. Directly causing ImportError does not do this. |
Progress: let m = help error line number with
sur_paren should be and normally is The HyperParser initialization correctly sees 'insert' as referring to line n. The problem is with get_surrounding_brackets. This is exposed to users as Edit => Show Surrounding Parens (default hotkey ^0 (zero) as least on Windows). Normally, if one types Debugging this appears to involve the separate pyparse module. A deep solution would be separate text widgets for code input and resulting output but I have only started a draft issue for this. What may be a factor is that Shell treat responses to executed input('prompt') statements, as with |
I've found a potential fix: I've replaced line 1744 in raise ImportError('No Python documentation found for %r.\nUse help() to get the interactive help utility.\nUse help(str) for help on the str class.' % thing) It seems to be fixed now. All calltips are now working properly after causing an incorrect input |
Actually, these kind of issues can be easily reproduced with code similar to the following: >>> class Y:
def __call__(self, ...):
if ...:
raise Exception('''...
...''')
>>> x = Y()
>>> x()
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
x()
File "<pyshell#10>", line 4, in __call__
raise Exception('''...
Exception: ...
... After this, every calltip gets replaced with Exception's Apparently, calltips need to be modified, not just |
Thank you. The help() bug is fixed, so a reproducer is needed to experiment and to test an fix in the main branch. The reduced code with comments.
Given that the fence-finder goes back too far, I think the unclosed More experiments: Please leave the title as I rewrote it. The best solution before splitting Shell as discussed above is to make the fence-finder in Shell start at the beginning of the statement. This should be possible now. But with help() fixed, I don't consider this a high priority. |
About the title, I think that'll be okay for now. It turns out the minimal required code to reproduce this is # killtip.py -- reproducer for https://github.com/python/cpython/issues/105689
# Running this will mess up calltips
raise ValueError("""
""") I would consider this a somewhat midline priority thing to fix because programs that raise multiline errors can mess up calltips for programs in interactive mode afterward (this bug is ONLY reproducible in interactive mode). |
Leave this bug open until fixed. |
When executing
help()
and giving an input of, say,
ghi
to the prompt,help
terminates with an error.However, the IDLE calltip for help changes from
to
(This is after ending the
help
session and typinghelp(
)What is weird is that if I do the same thing again, except that I provide an input of
abc
, as an example of a valid name, the calltip restores back to what it originally was.Besides, the calltip also changes for other names. If I reproduce this issue, and then I type
print(
, the same calltipcomes.
Is this intended behaviour?
NOTE: This behaviour is not specific to
help
. See #105689 (comment).My environment
(Note: I wanted to attach a picture, but calltips go away as soon as I take a screenshot)
The text was updated successfully, but these errors were encountered: