Skip to content

bpo-40334: Ensure that tok->type_comments is set on every path #19828

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Parser/pegen/pegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,8 @@ _PyPegen_Parser_New(struct tok_state *tok, int start_rule, int flags,
return (Parser *) PyErr_NoMemory();
}
assert(tok != NULL);
tok->type_comments = (flags & PyPARSE_TYPE_COMMENTS) > 0;
tok->async_hacks = (flags & PyPARSE_ASYNC_HACKS) > 0;
p->tok = tok;
p->keywords = NULL;
p->n_keyword_lists = -1;
Expand Down Expand Up @@ -1172,9 +1174,6 @@ _PyPegen_run_parser_from_string(const char *str, int start_rule, PyObject *filen

int parser_flags = compute_parser_flags(flags);
int feature_version = flags ? flags->cf_feature_version : PY_MINOR_VERSION;
tok->type_comments = (parser_flags & PyPARSE_TYPE_COMMENTS) > 0;
tok->async_hacks = (parser_flags & PyPARSE_ASYNC_HACKS) > 0;

Parser *p = _PyPegen_Parser_New(tok, start_rule, parser_flags, feature_version,
NULL, arena);
if (p == NULL) {
Expand Down