bpo-45822: Respect PEP 263's coding cookies in the parser even if flags are not provided (GH-29582)

This commit is contained in:
Pablo Galindo Salgado 2021-11-16 20:30:47 +00:00 committed by GitHub
parent d7e210070f
commit da20d7401d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 1 deletions

View file

@ -1463,7 +1463,7 @@ _PyPegen_run_parser_from_string(const char *str, int start_rule, PyObject *filen
int exec_input = start_rule == Py_file_input;
struct tok_state *tok;
if (flags == NULL || flags->cf_flags & PyCF_IGNORE_COOKIE) {
if (flags != NULL && flags->cf_flags & PyCF_IGNORE_COOKIE) {
tok = _PyTokenizer_FromUTF8(str, exec_input);
} else {
tok = _PyTokenizer_FromString(str, exec_input);