This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xtreak
Recipients emilyemorehouse, gvanrossum, xtreak
Date 2019-02-01.15:49:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1549036172.73.0.150719344025.issue35877@roundup.psfhosted.org>
In-reply-to
Content
> Emily, I think this would be as simple as making a tiny change to Grammar/Grammar and running make regen-grammar. Can you take care of that?

Thanks, can confirm that this fixes the issue. I changed test to namedexpr_test for while statement in grammar and ran `make regen-grammar` and `make`. The reported program runs fine and Lib/test/test_named_expressions.py also passes.

➜  cpython git:(master) ✗ cat /tmp/foo.py
import re

with open("/tmp/foo.py") as f:
    while line := f.readline():
        if match := re.search(r"foo", line):
            print(match.string.strip("\n"))
➜  cpython git:(master) ✗ ./python.exe /tmp/foo.py
with open("/tmp/foo.py") as f:
        if match := re.search(r"foo", line):


Patch : 

➜  cpython git:(master) ✗ git diff | cat
diff --git a/Grammar/Grammar b/Grammar/Grammar
index e65a688e4c..a425978059 100644
--- a/Grammar/Grammar
+++ b/Grammar/Grammar
@@ -72,7 +72,7 @@ assert_stmt: 'assert' test [',' test]
 compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated | async_stmt
 async_stmt: 'async' (funcdef | with_stmt | for_stmt)
 if_stmt: 'if' namedexpr_test ':' suite ('elif' namedexpr_test ':' suite)* ['else' ':' suite]
-while_stmt: 'while' test ':' suite ['else' ':' suite]
+while_stmt: 'while' namedexpr_test ':' suite ['else' ':' suite]
 for_stmt: 'for' exprlist 'in' testlist ':' [TYPE_COMMENT] suite ['else' ':' suite]
 try_stmt: ('try' ':' suite
            ((except_clause ':' suite)+
diff --git a/Python/graminit.c b/Python/graminit.c
index 6e0f19891b..5cdde2789c 100644
--- a/Python/graminit.c
+++ b/Python/graminit.c
@@ -971,7 +971,7 @@ static arc arcs_42_0[1] = {
     {103, 1},
 };
 static arc arcs_42_1[1] = {
-    {26, 2},
+    {99, 2},
 };
 static arc arcs_42_2[1] = {
     {27, 3},
History
Date User Action Args
2019-02-01 15:49:34xtreaksetrecipients: + xtreak, gvanrossum, emilyemorehouse
2019-02-01 15:49:32xtreaksetmessageid: <1549036172.73.0.150719344025.issue35877@roundup.psfhosted.org>
2019-02-01 15:49:32xtreaklinkissue35877 messages
2019-02-01 15:49:32xtreakcreate