summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2020-05-06 21:54:34 (GMT)
committerGitHub <noreply@github.com>2020-05-06 21:54:34 (GMT)
commit99db2a1db7a9b468a0ce8377d579f78fa03a2a34 (patch)
tree5752707eb45888e127ba1ae74721f2237a878f97 /Parser
parent441416c9a06f11f28e17d56c915ea6116c0c9ea7 (diff)
downloadcpython-99db2a1db7a9b468a0ce8377d579f78fa03a2a34.zip
cpython-99db2a1db7a9b468a0ce8377d579f78fa03a2a34.tar.gz
cpython-99db2a1db7a9b468a0ce8377d579f78fa03a2a34.tar.bz2
bpo-40334: Allow trailing comma in parenthesised context managers (GH-19964)
Diffstat (limited to 'Parser')
-rw-r--r--Parser/pegen/parse.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c
index 3b518ee..d863908 100644
--- a/Parser/pegen/parse.c
+++ b/Parser/pegen/parse.c
@@ -3031,9 +3031,9 @@ for_stmt_rule(Parser *p)
}
// with_stmt:
-// | 'with' '(' ','.with_item+ ')' ':' block
+// | 'with' '(' ','.with_item+ ','? ')' ':' block
// | 'with' ','.with_item+ ':' TYPE_COMMENT? block
-// | ASYNC 'with' '(' ','.with_item+ ')' ':' block
+// | ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block
// | ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block
static stmt_ty
with_stmt_rule(Parser *p)
@@ -3051,13 +3051,15 @@ with_stmt_rule(Parser *p)
UNUSED(start_lineno); // Only used by EXTRA macro
int start_col_offset = p->tokens[mark]->col_offset;
UNUSED(start_col_offset); // Only used by EXTRA macro
- { // 'with' '(' ','.with_item+ ')' ':' block
+ { // 'with' '(' ','.with_item+ ','? ')' ':' block
asdl_seq * a;
asdl_seq* b;
Token * keyword;
Token * literal;
Token * literal_1;
Token * literal_2;
+ void *opt_var;
+ UNUSED(opt_var); // Silence compiler warnings
if (
(keyword = _PyPegen_expect_token(p, 519))
&&
@@ -3065,6 +3067,8 @@ with_stmt_rule(Parser *p)
&&
(a = _gather_38_rule(p))
&&
+ (opt_var = _PyPegen_expect_token(p, 12), 1)
+ &&
(literal_1 = _PyPegen_expect_token(p, 8))
&&
(literal_2 = _PyPegen_expect_token(p, 11))
@@ -3124,7 +3128,7 @@ with_stmt_rule(Parser *p)
}
p->mark = mark;
}
- { // ASYNC 'with' '(' ','.with_item+ ')' ':' block
+ { // ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block
asdl_seq * a;
Token * async_var;
asdl_seq* b;
@@ -3132,6 +3136,8 @@ with_stmt_rule(Parser *p)
Token * literal;
Token * literal_1;
Token * literal_2;
+ void *opt_var;
+ UNUSED(opt_var); // Silence compiler warnings
if (
(async_var = _PyPegen_expect_token(p, ASYNC))
&&
@@ -3141,6 +3147,8 @@ with_stmt_rule(Parser *p)
&&
(a = _gather_42_rule(p))
&&
+ (opt_var = _PyPegen_expect_token(p, 12), 1)
+ &&
(literal_1 = _PyPegen_expect_token(p, 8))
&&
(literal_2 = _PyPegen_expect_token(p, 11))