]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-153171: Produce specialized syntax errors for 'not' after an operator in more...
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 6 Jul 2026 10:00:05 +0000 (13:00 +0300)
committerGitHub <noreply@github.com>
Mon, 6 Jul 2026 10:00:05 +0000 (13:00 +0300)
commit1034e73f699e858b2b7700d9e9b9ef692ccbad66
treea150b1bef5c4cdb13774c8d40f668ca1a4c5521a
parent8bee2a39b81ed1f77f01e220388a21a69bd4024b
gh-153171: Produce specialized syntax errors for 'not' after an operator in more positions (GH-153175)

Move the invalid_factor rule from term to factor and the
invalid_arithmetic rule from shift_expr to sum, so that they are
tried at all positions where the invalid construct can occur.
Previously a generic "invalid syntax" error was reported for
constructs like "1 << 2 + not x" or "1 * + not x".

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Grammar/python.gram
Lib/test/test_syntax.py
Misc/NEWS.d/next/Core_and_Builtins/2026-07-06-18-00-00.gh-issue-153171.errloc1.rst [new file with mode: 0644]
Parser/parser.c