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.

classification
Title: SystemError when using code.interact
Type: Stage: resolved
Components: Parser Versions: Python 3.11
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: aroberge, lys.nikolaou, pablogsal
Priority: normal Keywords:

Created on 2021-11-16 00:47 by aroberge, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
idle_problem.png aroberge, 2021-11-16 00:47
Messages (7)
msg406381 - (view) Author: Andre Roberge (aroberge) * Date: 2021-11-16 00:47
In the following, I execute a single invalid statement in the Python interpreter, which gives the correct error message. Afterwards, I repeat this example using code.interact(), generating a different traceback. This issue affects IDLE differently as shown in the attached file: the statement is never considered to be complete.

===
Python 3.11.0a2 (tags/v3.11.0a2:e2b4e4b, Nov  5 2021, 20:00:05) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 3 \ 4
  File "<stdin>", line 1
    a = 3 \ 4
            ^
SyntaxError: unexpected character after line continuation character
>>> import code
>>> code.interact()
Python 3.11.0a2 (tags/v3.11.0a2:e2b4e4b, Nov  5 2021, 20:00:05) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> a = 3 \ 4
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\andre\AppData\Local\Programs\Python\Python311\lib\code.py", line 301, in interact
    console.interact(banner, exitmsg)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\andre\AppData\Local\Programs\Python\Python311\lib\code.py", line 232, in interact
    more = self.push(line)
           ^^^^^^^^^^^^^^^
  File "C:\Users\andre\AppData\Local\Programs\Python\Python311\lib\code.py", line 258, in push
    more = self.runsource(source, self.filename)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\andre\AppData\Local\Programs\Python\Python311\lib\code.py", line 63, in runsource
    code = self.compile(source, filename, symbol)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\andre\AppData\Local\Programs\Python\Python311\lib\codeop.py", line 185, in __call__
    return _maybe_compile(self.compiler, source, filename, symbol)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\andre\AppData\Local\Programs\Python\Python311\lib\codeop.py", line 96, in _maybe_compile
    code2 = compiler(source + "\n\n", filename, symbol)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\andre\AppData\Local\Programs\Python\Python311\lib\codeop.py", line 150, in __call__
    codeob = compile(source, filename, symbol, self.flags, True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SystemError: Negative size passed to PyUnicode_New
msg406387 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-11-16 08:16
What versions does this affect? Only the main branch?
msg406389 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-11-16 09:02
I cannot reproduce this in the main branch:

❯ ./python.exe
Python 3.11.0a2+ (heads/main:9bf2cbc4c4, Nov 16 2021, 08:59:12) [Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import code
>>> code.interact()
Python 3.11.0a2+ (heads/main:9bf2cbc4c4, Nov 16 2021, 08:59:12) [Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> a = 3 \ 4
  File "<console>", line 1
    a = 3 \ 4
           ^
SyntaxError: unexpected character after line continuation character
>>> ^D
now exiting InteractiveConsole...
>>> a = 3 \ 4
  File "<stdin>", line 1
    a = 3 \ 4
           ^
SyntaxError: unexpected character after line continuation character
msg406390 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-11-16 09:07
Same with 3.10:

❯ ./python.exe
Python 3.10.0+ (heads/3.10:7c99e434a9, Nov 16 2021, 09:03:07) [Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 3 \ 4
  File "<stdin>", line 1
    a = 3 \ 4
           ^
SyntaxError: unexpected character after line continuation character
>>> import code
>>> code.interact()
Python 3.10.0+ (heads/3.10:7c99e434a9, Nov 16 2021, 09:03:07) [Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> a = 3 \ 4
  File "<console>", line 1
    a = 3 \ 4
           ^
SyntaxError: unexpected character after line continuation character

and 3.9:

❯ ./python.exe
Python 3.9.9+ (heads/3.9:a40d066e8e, Nov 16 2021, 09:02:19)
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 3 \ 4
  File "<stdin>", line 1
    a = 3 \ 4
           ^
SyntaxError: unexpected character after line continuation character
>>> import code
>>> code.interact()
Python 3.9.9+ (heads/3.9:a40d066e8e, Nov 16 2021, 09:02:19)
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> a = 3 \ 4
  File "<console>", line 1
    a = 3 \ 4
           ^
SyntaxError: unexpected character after line continuation character
msg406391 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-11-16 09:09
You seem to be using commit e2b4e4b (the release commit), but this issue was fixed very likely in https://bugs.python.org/issue45738.

Could you confirm that you cannot reproduce this with the latest main branch? In general, I would kindly recommend to always do this check when opening a new issue :)
msg406394 - (view) Author: Andre Roberge (aroberge) * Date: 2021-11-16 10:35
I am sorry, but I am not set up to work from the main branch and must rely on official releases.  In the future, for alpha and beta releases, I will try to wait for the next release, see immediately if I can reproduce bugs that I had noted before, and submit then at that time.
msg406398 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-11-16 11:14
In that case don't worry. I prefer that you report potential bugs without waiting if that's ok with you, my comment was just in case you are familiar with compiling from the CPython repo.

Thanks for all the help!
History
Date User Action Args
2022-04-11 14:59:52adminsetgithub: 89970
2021-11-16 11:14:08pablogsalsetmessages: + msg406398
2021-11-16 10:35:33arobergesetstatus: open -> closed

messages: + msg406394
stage: resolved
2021-11-16 09:09:39pablogsalsetmessages: + msg406391
2021-11-16 09:07:30pablogsalsetmessages: + msg406390
2021-11-16 09:02:43pablogsalsetmessages: + msg406389
2021-11-16 08:16:45pablogsalsetmessages: + msg406387
2021-11-16 00:47:43arobergecreate