diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-10-31 02:16:05 +0000 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-10-31 02:16:05 +0000 |
commit | dcee09d9204957ace381b1c3507259f718aa4907 (patch) | |
tree | bb1bee26c4b535f8e9dd75f25a1ef1a72735e880 /Python/pythonrun.c | |
parent | 44a90c95ceb6d6348dd7f81db33287f09112118d (diff) | |
download | cpython-git-dcee09d9204957ace381b1c3507259f718aa4907.tar.gz |
make sure the parser flags and passed onto the compiler
This fixes "from __future__ import unicode_literals" in an exec statment
See #4225
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index bdd9bd7d88..4ff70d8543 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1417,16 +1417,19 @@ PyParser_ASTFromString(const char *s, const char *filename, int start, PyCompilerFlags *flags, PyArena *arena) { mod_ty mod; + PyCompilerFlags localflags; perrdetail err; int iflags = PARSER_FLAGS(flags); node *n = PyParser_ParseStringFlagsFilenameEx(s, filename, &_PyParser_Grammar, start, &err, &iflags); + if (flags == NULL) { + localflags.cf_flags = 0; + flags = &localflags; + } if (n) { - if (flags) { - flags->cf_flags |= iflags & PyCF_MASK; - } + flags->cf_flags |= iflags & PyCF_MASK; mod = PyAST_FromNode(n, flags, filename, arena); PyNode_Free(n); return mod; @@ -1443,15 +1446,18 @@ PyParser_ASTFromFile(FILE *fp, const char *filename, int start, char *ps1, PyArena *arena) { mod_ty mod; + PyCompilerFlags localflags; perrdetail err; int iflags = PARSER_FLAGS(flags); node *n = PyParser_ParseFileFlagsEx(fp, filename, &_PyParser_Grammar, start, ps1, ps2, &err, &iflags); + if (flags == NULL) { + localflags.cf_flags = 0; + flags = &localflags; + } if (n) { - if (flags) { - flags->cf_flags |= iflags & PyCF_MASK; - } + flags->cf_flags |= iflags & PyCF_MASK; mod = PyAST_FromNode(n, flags, filename, arena); PyNode_Free(n); return mod; |