-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3.11 exec raises SystemError instead of SyntaxError on char after line continuation #89901
Comments
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 |
It looks like this also affects Python 3.9.8, which makes me very suspicious of https://bugs.python.org/issue45494 as the probable cause. See Zac-HD/hypothesmith#16 and psf/black#2592 (comment) for reports. |
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 |
I will be able to take a look later in the weekend, so if someone is able to give it a go before, that would be great. |
Please take some time for yourself, I added you as you were the original author of the patch to make you aware. I believe most projects can workaround that for now. |
This should be fixed by now, but please, check if everything is in order in your respective test suites and confirm here. |
Seems to work. Thanks! |
Works for me as well. Thanks. |
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
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: