[issue45738] 3.11 exec raises SystemError instead of SyntaxError on char after line continuation

PEW's Corner report at bugs.python.org
Sat Nov 6 09:10:52 EDT 2021


New submission from PEW's Corner <pewscorner at gmail.com>:

When exec'ing code with an illegal character after the line continuation character '\', python 3.11.0a2 raises this strange exception:

  SystemError: Negative size passed to PyUnicode_New

Here's an example where '#' is the illegal character:

  exec('1,\\#\n2')

I expected the following exception (which is raised by Python 3.10.0, and also by Python 3.11.0a2 when using eval instead of exec, or when the string content is put into its own file and run as a normal script):

  SyntaxError: unexpected character after line continuation character

----------
messages: 405860
nosy: pewscorner
priority: normal
severity: normal
status: open
title: 3.11 exec raises SystemError instead of SyntaxError on char after line continuation
type: behavior
versions: Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45738>
_______________________________________


More information about the Python-bugs-list mailing list