Skip to content

[3.15] gh-157451: Fix gettext.c2py() for unary "!" combined with a binary operator (GH-157453) - #157663

Open
miss-islington wants to merge 1 commit into
python:3.15from
miss-islington:backport-01192a8-3.15
Open

miss-islington wants to merge 1 commit into
python:3.15from
miss-islington:backport-01192a8-3.15

Conversation

@miss-islington

@miss-islington miss-islington commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

In C the unary "!" operator binds tighter than binary operators, but "not"
binds looser in Python, so "!n + 1" was translated to "not n + 1". "!" as
the right operand of a binary operator, for example "2 * !n", produced
invalid Python code and raised SyntaxError.
(cherry picked from commit 01192a8)

Co-authored-by: Madan Kumar [email protected]
Co-authored-by: Serhiy Storchaka [email protected]

…ary operator (pythonGH-157453)

In C the unary "!" operator binds tighter than binary operators, but "not"
binds looser in Python, so "!n + 1" was translated to "not n + 1".  "!" as
the right operand of a binary operator, for example "2 * !n", produced
invalid Python code and raised SyntaxError.
(cherry picked from commit 01192a8)

Co-authored-by: Madan Kumar <[email protected]>
Co-authored-by: Serhiy Storchaka <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants