-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
codeop: inconsistent handling of invalid escapes #96052
Comments
It is because the When run Python with the
The first warning (starting with ":1:") is emitted by the REPL. The second one (starting with ":2:"). And finally you get an error when Duplicated warnings were silenced in bpo-40807, and turned into errors in bpo-41520. @vstinner |
I'm no longer sure if codeop should display SyntaxError or raise an exception by default (see issue #85692). But I dislike the fact that warnings depends if the first or the second compile() function succeeded. We can to treat warnings the same way for all compile() calls. |
…input Previously codeop.compile_command() emitted compiler warnings (SyntaxWarning or DeprecationWarning) and raised a SyntaxError for incomplete input containing a potentially incorrect code. Now it always returns None for incomplete input without emitting any warnings.
…input Previously codeop.compile_command() emitted compiler warnings (SyntaxWarning or DeprecationWarning) and raised a SyntaxError for incomplete input containing a potentially incorrect code. Now it always returns None for incomplete input without emitting any warnings.
…H-96132) Previously codeop.compile_command() emitted compiler warnings (SyntaxWarning or DeprecationWarning) and raised a SyntaxError for incomplete input containing a potentially incorrect code. Now it always returns None for incomplete input without emitting any warnings.
…input (pythonGH-96132) Previously codeop.compile_command() emitted compiler warnings (SyntaxWarning or DeprecationWarning) and raised a SyntaxError for incomplete input containing a potentially incorrect code. Now it always returns None for incomplete input without emitting any warnings. (cherry picked from commit 426d72e) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…input (pythonGH-96132) Previously codeop.compile_command() emitted compiler warnings (SyntaxWarning or DeprecationWarning) and raised a SyntaxError for incomplete input containing a potentially incorrect code. Now it always returns None for incomplete input without emitting any warnings. (cherry picked from commit 426d72e) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…H-96132) Previously codeop.compile_command() emitted compiler warnings (SyntaxWarning or DeprecationWarning) and raised a SyntaxError for incomplete input containing a potentially incorrect code. Now it always returns None for incomplete input without emitting any warnings. (cherry picked from commit 426d72e) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…H-96132) Previously codeop.compile_command() emitted compiler warnings (SyntaxWarning or DeprecationWarning) and raised a SyntaxError for incomplete input containing a potentially incorrect code. Now it always returns None for incomplete input without emitting any warnings. (cherry picked from commit 426d72e) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@serhiy-storchaka: Is this issue fixed or not? It's still open. Issue #97562 can be closed as a duplicate if I understood correctly. |
Yes, this issue has been fixed. |
No, this change was not included in 3.11rc2 and 3.10.7. You have to wait the next bugfix releases. |
Bug report
It seems like the
codeop
module is inconsistent with regards to handling of invalid escapes. For example,'\('
is accepted at the top level, but apparently not within indented blocks.This can also be seen when submitting code via IDLE; e.g.
However, such code is accepted by a "plain" Python terminal:
Given the discrepancy, it seems like invalid escapes should perhaps be accepted by
codeop
here?Your environment
Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32
The text was updated successfully, but these errors were encountered: