[issue43379] Pasting multiple lines in the REPL is broken since 3.9
New submission from Romain Vincent : DISCLAIMER: This is the first time I submit an issue here. In advance, my humble apologies if I missed something. Feel free to correct me :) -- I regularly test snippets of code by pasting them from a code editor to a shell REPL. It works perfectly well in python 3.8 or 3.7 but not in python 3.9. Demonstration: Try to copy and paste the following simple snippet: --- def f(): print("hello world") --- The result in a python 3.8 REPL (same with 3.7): --- $ python3.8 Python 3.8.6 (default, Nov 20 2020, 18:29:40) [Clang 12.0.0 (clang-1200.0.32.27)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> def f(): print("hello world") >>> f() hello world --- But with python 3.9: --- $ python3.9 Python 3.9.1 (default, Dec 10 2020, 10:36:35) [Clang 12.0.0 (clang-1200.0.32.27)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> def f(): print("hello world") File "", line 1 ^ SyntaxError: multiple statements found while compiling a single statement --- This behavior happens with any snippet of code containing at least one indented line, whether by tabs or spaces and whatever the number of spaces. Regards. -- components: IO messages: 387976 nosy: romainfv priority: normal severity: normal status: open title: Pasting multiple lines in the REPL is broken since 3.9 type: behavior versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue43379> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43379] Pasting multiple lines in the REPL is broken since 3.9
Romain Vincent added the comment: The lack of dots was something I noticed. So from your questions (Ned Deily) I have been testing out several things and found a "wae"! But first, to answer your questions: 1. both LF and CRLF and it didn't change anything. 2. Running "import readline;print(readline.__doc__)" prints "... GNU readline", with python 3.7, 3.8 and 3.9. 3. I am using iTerm2, but the problem also happens on MacOS's native Terminal.app. Versions of python were installed with **homebrew**. Maybe worth to mention: if I paste my code in a multi line string to execute with python -c, then it works properly. e.g. --- python3.9 -i -c 'a = 42 if a: print("hello world") ' hello world >>> --- The example is different because I realized I had the same problem on python3.7 and python3.8 when the 2 first lines were at the same level of indentation (Note sure if this gives a hint as to what the problem is). HOWEVER, if I use python versions directly downloaded from https://www.python.org/, then I don't have the problem at all! Demonstration: --- /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 Python 3.7.2 (v3.7.2:9a3ffc0492, Dec 24 2018, 02:44:43) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import readline;print(readline.__doc__) Importing this module enables command line editing using libedit readline. >>> a = 42 >>> if a: ... print("hello world") ... hello world >>> --- Same for python3.9 -- ___ Python tracker <https://bugs.python.org/issue43379> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com