From 084ce7a5dcadc2d1bac565a363ae54bbcb09abd0 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Fri, 31 Oct 2008 02:26:20 +0000 Subject: Merged revisions 67066 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r67066 | benjamin.peterson | 2008-10-30 21:16:05 -0500 (Thu, 30 Oct 2008) | 5 lines make sure the parser flags and passed onto the compiler This fixes "from __future__ import unicode_literals" in an exec statment See #4225 ........ --- Python/pythonrun.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'Python/pythonrun.c') 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; -- cgit v1.2.1