Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 49624:f3234e43e1fe
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
........
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Fri, 31 Oct 2008 02:28:05 +0000 |
| parents | efef5fc45a9a |
| children | 630c174b465e |
comparison
equal
deleted
inserted
replaced
| 49620:3e2de484ce34 | 49624:f3234e43e1fe |
|---|---|
| 1686 mod_ty | 1686 mod_ty |
| 1687 PyParser_ASTFromString(const char *s, const char *filename, int start, | 1687 PyParser_ASTFromString(const char *s, const char *filename, int start, |
| 1688 PyCompilerFlags *flags, PyArena *arena) | 1688 PyCompilerFlags *flags, PyArena *arena) |
| 1689 { | 1689 { |
| 1690 mod_ty mod; | 1690 mod_ty mod; |
| 1691 PyCompilerFlags localflags; | |
| 1691 perrdetail err; | 1692 perrdetail err; |
| 1692 int iflags = PARSER_FLAGS(flags); | 1693 int iflags = PARSER_FLAGS(flags); |
| 1693 | 1694 |
| 1694 node *n = PyParser_ParseStringFlagsFilenameEx(s, filename, | 1695 node *n = PyParser_ParseStringFlagsFilenameEx(s, filename, |
| 1695 &_PyParser_Grammar, start, &err, | 1696 &_PyParser_Grammar, start, &err, |
| 1696 &iflags); | 1697 &iflags); |
| 1698 if (flags == NULL) { | |
| 1699 localflags.cf_flags = 0; | |
| 1700 flags = &localflags; | |
| 1701 } | |
| 1697 if (n) { | 1702 if (n) { |
| 1698 if (flags) { | 1703 flags->cf_flags |= iflags & PyCF_MASK; |
| 1699 flags->cf_flags |= iflags & PyCF_MASK; | |
| 1700 } | |
| 1701 mod = PyAST_FromNode(n, flags, filename, arena); | 1704 mod = PyAST_FromNode(n, flags, filename, arena); |
| 1702 PyNode_Free(n); | 1705 PyNode_Free(n); |
| 1703 return mod; | 1706 return mod; |
| 1704 } | 1707 } |
| 1705 else { | 1708 else { |
| 1713 int start, char *ps1, | 1716 int start, char *ps1, |
| 1714 char *ps2, PyCompilerFlags *flags, int *errcode, | 1717 char *ps2, PyCompilerFlags *flags, int *errcode, |
| 1715 PyArena *arena) | 1718 PyArena *arena) |
| 1716 { | 1719 { |
| 1717 mod_ty mod; | 1720 mod_ty mod; |
| 1721 PyCompilerFlags localflags; | |
| 1718 perrdetail err; | 1722 perrdetail err; |
| 1719 int iflags = PARSER_FLAGS(flags); | 1723 int iflags = PARSER_FLAGS(flags); |
| 1720 | 1724 |
| 1721 node *n = PyParser_ParseFileFlagsEx(fp, filename, enc, | 1725 node *n = PyParser_ParseFileFlagsEx(fp, filename, enc, |
| 1722 &_PyParser_Grammar, | 1726 &_PyParser_Grammar, |
| 1723 start, ps1, ps2, &err, &iflags); | 1727 start, ps1, ps2, &err, &iflags); |
| 1728 if (flags == NULL) { | |
| 1729 localflags.cf_flags = 0; | |
| 1730 flags = &localflags; | |
| 1731 } | |
| 1724 if (n) { | 1732 if (n) { |
| 1725 if (flags) { | 1733 flags->cf_flags |= iflags & PyCF_MASK; |
| 1726 flags->cf_flags |= iflags & PyCF_MASK; | |
| 1727 } | |
| 1728 mod = PyAST_FromNode(n, flags, filename, arena); | 1734 mod = PyAST_FromNode(n, flags, filename, arena); |
| 1729 PyNode_Free(n); | 1735 PyNode_Free(n); |
| 1730 return mod; | 1736 return mod; |
| 1731 } | 1737 } |
| 1732 else { | 1738 else { |
