You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See discussion here. Note that the code sample sent by Ron was correctly formatted in email, but has lost all indentation in the Discuss website.
Rename the attached blank.txt to blank.py. (Github will not allow you to upload .py files!)
Run the renamed blank.py file from the command line, e.g. python3.10 blank.py. Note that it will run correctly from the vanilla Python interpreter.
Launch the CPython interactive interpreter (REPL). Copy and paste the contents of blank.py using the editor of your choice, and paste it into the REPL at the >>> prompt. Notice that the blank line after the function correctly resets the prompt and the code will correctly run.
Steps to reproduce
Launch IDLE.
Copy the contents of blank.py using your preferred text editor, including the blank line after the return, and the following outdented function call.
Paste it at the >>> prompt.
Note that, unlike the CPython REPL, the blank line does not reset the prompt to >>> but it remains the level 2 prompt ... instead.
IDLE wrongly reports a syntax error: SyntaxError: invalid syntax.
Expected behaviour
The behaviour should match the CPython interactive interpreter, or at the very least, a better error message should be given. See also issue #93307
def blank():
print("blank")
blank() # Blank line above this.
This feature change request is a duplicate of #47809 and possibly #51989. The REPL treats pasted text the same as entered text. Hence it feeds lines to python 1 at a time. Tcl/tk pastes the entire code into a text widget all at once. IDLE intentionally allows user to edit pasted code before submitting it for execution with . IDLE, via code.InteractiveInterpreter and codeop, compiles statements with compile(..., mode='single') and submits the returned code object for execution. Multiple statements are an error for 'single' mode.
See discussion here. Note that the code sample sent by Ron was correctly formatted in email, but has lost all indentation in the Discuss website.
Rename the attached blank.txt to blank.py. (Github will not allow you to upload .py files!)
Run the renamed blank.py file from the command line, e.g.
python3.10 blank.py
. Note that it will run correctly from the vanilla Python interpreter.Launch the CPython interactive interpreter (REPL). Copy and paste the contents of blank.py using the editor of your choice, and paste it into the REPL at the
>>>
prompt. Notice that the blank line after the function correctly resets the prompt and the code will correctly run.Steps to reproduce
return
, and the following outdented function call.>>>
prompt.>>>
but it remains the level 2 prompt...
instead.SyntaxError: invalid syntax
.Expected behaviour
The behaviour should match the CPython interactive interpreter, or at the very least, a better error message should be given. See also issue #93307
blank.txt
The text was updated successfully, but these errors were encountered: