Skip to content

Commit d9d6ead

Browse files
authored
Ensure that tok->type_comments is set on every path (GH-19828)
1 parent 3941d97 commit d9d6ead

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Parser/pegen/pegen.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,8 @@ _PyPegen_Parser_New(struct tok_state *tok, int start_rule, int flags,
10171017
return (Parser *) PyErr_NoMemory();
10181018
}
10191019
assert(tok != NULL);
1020+
tok->type_comments = (flags & PyPARSE_TYPE_COMMENTS) > 0;
1021+
tok->async_hacks = (flags & PyPARSE_ASYNC_HACKS) > 0;
10201022
p->tok = tok;
10211023
p->keywords = NULL;
10221024
p->n_keyword_lists = -1;
@@ -1172,9 +1174,6 @@ _PyPegen_run_parser_from_string(const char *str, int start_rule, PyObject *filen
11721174

11731175
int parser_flags = compute_parser_flags(flags);
11741176
int feature_version = flags ? flags->cf_feature_version : PY_MINOR_VERSION;
1175-
tok->type_comments = (parser_flags & PyPARSE_TYPE_COMMENTS) > 0;
1176-
tok->async_hacks = (parser_flags & PyPARSE_ASYNC_HACKS) > 0;
1177-
11781177
Parser *p = _PyPegen_Parser_New(tok, start_rule, parser_flags, feature_version,
11791178
NULL, arena);
11801179
if (p == NULL) {

0 commit comments

Comments
 (0)