summaryrefslogtreecommitdiffstats
path: root/Parser/pegen
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2020-05-01 16:42:32 (GMT)
committerGitHub <noreply@github.com>2020-05-01 16:42:32 (GMT)
commitd9d6eadf003605f4cdb55e38df2168dd1bc0dbd5 (patch)
tree00df3dd19f5757d6cef5393165b0ec1d90e4db30 /Parser/pegen
parent3941d9700b2a272689cb8a8435b5c60a1466ef79 (diff)
downloadcpython-d9d6eadf003605f4cdb55e38df2168dd1bc0dbd5.zip
cpython-d9d6eadf003605f4cdb55e38df2168dd1bc0dbd5.tar.gz
cpython-d9d6eadf003605f4cdb55e38df2168dd1bc0dbd5.tar.bz2
Ensure that tok->type_comments is set on every path (GH-19828)
Diffstat (limited to 'Parser/pegen')
-rw-r--r--Parser/pegen/pegen.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/Parser/pegen/pegen.c b/Parser/pegen/pegen.c
index a7add8f..6ff09b3 100644
--- a/Parser/pegen/pegen.c
+++ b/Parser/pegen/pegen.c
@@ -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;
@@ -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) {