Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd4fceaa

Browse files
tirkarthiemilyemorehouse
authored andcommitted
bpo-35877: Make parenthesis optional for named expression in while statement (GH-11724)
* Add parenthesis optional in named expressions for while statement* Add NEWS entry
1 parent85d83ec commitd4fceaa

File tree

4 files changed

+5
-2
lines changed

4 files changed

+5
-2
lines changed

‎Grammar/Grammar‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ assert_stmt: 'assert' test [',' test]
7272
compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated | async_stmt
7373
async_stmt: 'async' (funcdef | with_stmt | for_stmt)
7474
if_stmt: 'if' namedexpr_test ':' suite ('elif' namedexpr_test ':' suite)* ['else' ':' suite]
75-
while_stmt: 'while'test ':' suite ['else' ':' suite]
75+
while_stmt: 'while'namedexpr_test ':' suite ['else' ':' suite]
7676
for_stmt: 'for' exprlist 'in' testlist ':' [TYPE_COMMENT] suite ['else' ':' suite]
7777
try_stmt: ('try' ':' suite
7878
((except_clause ':' suite)+

‎Lib/test/test_parser.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ def test_named_expressions(self):
426426
self.check_suite("(a := 1)")
427427
self.check_suite("(a := a)")
428428
self.check_suite("if (match := pattern.search(data)) is None: pass")
429+
self.check_suite("while match := pattern.search(f.read()): pass")
429430
self.check_suite("[y := f(x), y**2, y**3]")
430431
self.check_suite("filtered_data = [y for x in data if (y := f(x)) is None]")
431432
self.check_suite("(y := f(x))")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Make parenthesis optional for named expressions in while statement. Patch by
2+
Karthikeyan Singaravelan.

‎Python/graminit.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ static arc arcs_42_0[1] = {
971971
{103,1},
972972
};
973973
staticarcarcs_42_1[1]= {
974-
{26,2},
974+
{99,2},
975975
};
976976
staticarcarcs_42_2[1]= {
977977
{27,3},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp