3.11 exec raises SystemError instead of SyntaxError on char after line continuation #89901
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
assignee = None closed_at = <Date 2021-11-14.13:59:48.259> created_at = <Date 2021-11-06.13:10:51.997> labels = ['type-bug', '3.9', '3.11'] title = '3.11 exec raises SystemError instead of SyntaxError on char after line continuation' updated_at = <Date 2021-11-14.18:39:21.628> user = 'https://github.com/pewscorner'
activity = <Date 2021-11-14.18:39:21.628> actor = 'mbussonn' assignee = 'none' closed = True closed_date = <Date 2021-11-14.13:59:48.259> closer = 'pablogsal' components =  creation = <Date 2021-11-06.13:10:51.997> creator = 'pewscorner' dependencies =  files =  hgrepos =  issue_num = 45738 keywords = ['patch'] message_count = 12.0 messages = ['405860', '406188', '406223', '406224', '406235', '406236', '406301', '406303', '406304', '406305', '406322', '406329'] nosy_count = 8.0 nosy_names = ['aroberge', 'mbussonn', 'lys.nikolaou', 'Zac Hatfield-Dodds', 'pablogsal', 'miss-islington', 'BTaskaya', 'pewscorner'] pr_nums = ['29550', '29551', '29552'] priority = 'normal' resolution = 'fixed' stage = 'resolved' status = 'closed' superseder = None type = 'behavior' url = 'https://bugs.python.org/issue45738' versions = ['Python 3.9', 'Python 3.11']
The text was updated successfully, but these errors were encountered:
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:
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
Yep, this also break IPython command completions when users press tab in some places in multiline code.
88f4ec8 is the first offending commit for me in the 3.9 branch:
Note that with the following example, exec and CommandCompiler return a different error:
from codeop import CommandCompiler
# one is syntax the other is System. exec('a \ \n') # SyntaxError CommandCompiler()('a \ \n', symbol='exec') # SystemError