bpo-41697: Correctly handle KeywordOrStarred when parsing arguments in the parser (GH-22077)
diff --git a/Parser/parser.c b/Parser/parser.c
index 3e724a2..8a7cb62 100644
--- a/Parser/parser.c
+++ b/Parser/parser.c
@@ -12237,7 +12237,16 @@
)
{
D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.(starred_expression | named_expression !'=')+ [',' kwargs]"));
- _res = _PyPegen_collect_call_seqs ( p , a , b );
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _PyPegen_collect_call_seqs ( p , a , b , EXTRA );
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
D(p->level--);