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.

Title: PEG parser disables IDLE Shell input > 2 lines
Type: compile error Stage: resolved
Components: IDLE, Interpreter Core, Library (Lib) Versions: Python 3.9
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: lukasz.langa, lys.nikolaou, pablogsal, rhettinger, terry.reedy
Priority: high Keywords:

Created on 2020-05-01 19:35 by rhettinger, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg367875 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-05-01 19:35
In Python3.8 and prior, you can type this in a shell session

Python 3.8.2 (v3.8.2:7b3ab5921f, Feb 24 2020, 17:52:18) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license()" for more information.
>>> def square(x):
	s = x ** 2
	return s

In Python3.9, the input is terminated prematurely

Python 3.9.0a6 (v3.9.0a6:bc1c8af8ef, Apr 27 2020, 17:05:28) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license()" for more information.
>>> def square(x):
	s = x ** 2             # <-- On first return, the statement evaluates

>>> square(5)
msg367906 - (view) Author: Dennis Sweeney (Dennis Sweeney) * (Python committer) Date: 2020-05-02 01:26
git bisect says that this was fixed here:

commit b94dbd7ac34dc0c79512656eb17f6f07e09fca7a
Author: Pablo Galindo <>
Date:   Mon Apr 27 18:35:58 2020 +0100

    bpo-40334: Support PyPARSE_DONT_IMPLY_DEDENT in the new parser (GH-19736)
msg367909 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-05-02 03:15
Thank you Dennis.  I was just about to post that after installing 3.8.3rc1 and 3.9.0a6 in a Macbook Air, with identical idlelib code, I confirmed the problem as specific to 3.9 and that

$ python3.9 -X oldparser -m idlelib

works around the issue.  My python development desktop is currently in a  repair shop. I will try to verify the fix on Windows master when I can.

idlelib.pyshell.ModifiedInterpreter subclasses code.InteractiveInterpreter.  After each 'Enter', something calls compile(current_lines,  '<input>','single').  Something changed that makes a difference in one of the files.

The only thing I found is that the error for 'if 1:\n' changed from "SyntaxError: unexpected EOF ..." to "IndentationError: expected ...".  Since issubclass(IndentationError, SyntaxError), I would not expect that to be a problem, but if Pablo fixed this, good enough for me.  So I am closing until someone says otherwise.
Date User Action Args
2022-04-11 14:59:30adminsetgithub: 84652
2020-05-02 03:15:33terry.reedysetstatus: open -> closed

resolution: out of date

assignee: terry.reedy ->
stage: resolved
title: IDLE Shell not allowing more than two line inputs -> PEG parser disables IDLE Shell input > 2 lines
nosy: + lukasz.langa, lys.nikolaou, pablogsal, - Dennis Sweeney
messages: + msg367909
components: + Interpreter Core, Library (Lib)
type: compile error
2020-05-02 01:26:15Dennis Sweeneysetnosy: + Dennis Sweeney
messages: + msg367906
2020-05-01 19:35:30rhettingercreate