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: unrequested pasting into Shell after restart #79648
Comments
IDLE very occasionally (frequency much less than .01), and AFAIK hapzardly, pastes previous shell output after I enter something at the prompt after a restart. Not fatal but definitly annoying. When it happened today, I decided to open this issue to start accumulating information that might point at where to start. tem3.py: (content likely not relevant) import inspect
class A:
pass
print(inspect.getsource(A))
print(__name__) Shell copy:
"""
...
OSError: could not find class definition
>>>
======================== RESTART: F:\Python\a\tem3.py ======================== class A:
pass __main__
>>> 1/0======================== RESTART: F:\Python\a\tem3.py ======================== class A:
pass
SyntaxError: invalid syntax
>>> 1/0
Traceback (most recent call last):
...
""" The paste, after '1/0', is the restart line and the first two lines of output (but not the last two). It mixes text from IDLE and from the program, so it is not an echo from the run process). It is colored as if typed in: 'class' and 'pass' are keyword colored, the I believe I hit ENTER and got the paste instead of the exception. I hit Entere after the paste to get the SyntaxError and a clean prompt. Then I reentered 1/0. I did more or less the same thing about 5 times without a repeat of the problem. Possible factors: Included Content: Raymond, I believe you have seen this on Mac. Tal or Sheryl, how about linux? Anyone, more details on other examples are needed to know what is constant and what is incidental. |
I don't believe I've seen this happen, but I'll watch for it. One thing that I noticed while trying to recreate it is that I can press F5 on the Shell window even though there isn't a Run menu. Maybe the issue is somehow related using shortcuts that aren't defined for Shell. |
Thank you for the report. Since I expect you would recognize the issue if you had seen it, I consider it possible that linux IDLE is immune. After running a file, I would like f5 to re-run the same file. Trying to run the contents of Shell, starting with the start-up message, is laughably useless. |
FWIW, I have this problem every day. Am running on macOS. This behavior has been seen for years and still persists on the latest IDLE that ships with a stock 3.7.1 from python.org. |
Raymond: I agree that daily would be obnoxious. For me it is more like once a month or maybe less. Can you give any detail about the factors I mentioned? I currently have no idea where to start looking. |
I finally caught an example, which was not immediately after restart. I copied the two lines of output, entered 'import re\n' and the copied text was pasted, then the line with the addition compiled, leading to the error. Type "help", "copyright", "credits" or "license()" for more information.
>>> for c in '℘·': hex(ord(c))
...
'0x2118'
'0xb7'
>>> import re'0x2118'
... '0xb7'
SyntaxError: invalid syntax
>>> for c in '℘·': hex(ord(c)) I pasted the copied output into an issue on the browser and did other stuff before coming back to this window to try something with re. Differences from my initial report: No RESTART (though usually or often is), no exception, not first entry (but first time not?). Edit menu item 'Paste' and the shortcut are bound to IDLE-defined pseudoevent '<<paste>>' which invokes method EditorWindow.paste which calls event_generate('<<Paste>>'), where the latter event is a tk-defined event. Where triggered? I could add a print-to-console in .paste? Happening only in shell and after Enter suggest looking as shell-specific part of Enter handling. If never on Linux, could x-11-only fix-x11-paste (called in pyshell.main) explain why not? I searched stackoverflow [tkinter] questions for 'paste'. Got 840 responses, looked as first page, saw nothing relevant. Adding 'unwanted', 'unexpected', or 'spontaneous' resulted in no hits. I will consider asking a question myself. |
Fairly consistent reproducer (at least 10 times): open Shell and editor (no code needed); copy from Shell; switch to editor; hts F5; after >>> and maybe entry, hit return. Copied text is pasted. Does not happen if much of any extra action after paste. Or F5 to restart, select, ^C to copy, return (without clicking to move cursor back to prompt), and copied text is pasted after prompt. (The prompt is now in sidebar, but issue predates it by years.) Hit return and get error. Can repeat copy, return, and unexpected-paste followed by error as long as only click to select and only hit return after copy. I tried experiment above of adding |
I did a copy with prompts of the first 3 lines before entering the 4th and getting the unwanted copy pasted. |
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: