Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 49623:6cac2e3077a3 2.6
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:26:20 +0000 |
| parents | b1682c693b9a |
| children | 5d9be65e7891 |
comparison
equal
deleted
inserted
replaced
| 49619:06cf2cea387b | 49623:6cac2e3077a3 |
|---|---|
| 1415 mod_ty | 1415 mod_ty |
| 1416 PyParser_ASTFromString(const char *s, const char *filename, int start, | 1416 PyParser_ASTFromString(const char *s, const char *filename, int start, |
| 1417 PyCompilerFlags *flags, PyArena *arena) | 1417 PyCompilerFlags *flags, PyArena *arena) |
| 1418 { | 1418 { |
| 1419 mod_ty mod; | 1419 mod_ty mod; |
| 1420 PyCompilerFlags localflags; | |
| 1420 perrdetail err; | 1421 perrdetail err; |
| 1421 int iflags = PARSER_FLAGS(flags); | 1422 int iflags = PARSER_FLAGS(flags); |
| 1422 | 1423 |
| 1423 node *n = PyParser_ParseStringFlagsFilenameEx(s, filename, | 1424 node *n = PyParser_ParseStringFlagsFilenameEx(s, filename, |
| 1424 &_PyParser_Grammar, start, &err, | 1425 &_PyParser_Grammar, start, &err, |
| 1425 &iflags); | 1426 &iflags); |
| 1427 if (flags == NULL) { | |
| 1428 localflags.cf_flags = 0; | |
| 1429 flags = &localflags; | |
| 1430 } | |
| 1426 if (n) { | 1431 if (n) { |
| 1427 if (flags) { | 1432 flags->cf_flags |= iflags & PyCF_MASK; |
| 1428 flags->cf_flags |= iflags & PyCF_MASK; | |
| 1429 } | |
| 1430 mod = PyAST_FromNode(n, flags, filename, arena); | 1433 mod = PyAST_FromNode(n, flags, filename, arena); |
| 1431 PyNode_Free(n); | 1434 PyNode_Free(n); |
| 1432 return mod; | 1435 return mod; |
| 1433 } | 1436 } |
| 1434 else { | 1437 else { |
| 1441 PyParser_ASTFromFile(FILE *fp, const char *filename, int start, char *ps1, | 1444 PyParser_ASTFromFile(FILE *fp, const char *filename, int start, char *ps1, |
| 1442 char *ps2, PyCompilerFlags *flags, int *errcode, | 1445 char *ps2, PyCompilerFlags *flags, int *errcode, |
| 1443 PyArena *arena) | 1446 PyArena *arena) |
| 1444 { | 1447 { |
| 1445 mod_ty mod; | 1448 mod_ty mod; |
| 1449 PyCompilerFlags localflags; | |
| 1446 perrdetail err; | 1450 perrdetail err; |
| 1447 int iflags = PARSER_FLAGS(flags); | 1451 int iflags = PARSER_FLAGS(flags); |
| 1448 | 1452 |
| 1449 node *n = PyParser_ParseFileFlagsEx(fp, filename, &_PyParser_Grammar, | 1453 node *n = PyParser_ParseFileFlagsEx(fp, filename, &_PyParser_Grammar, |
| 1450 start, ps1, ps2, &err, &iflags); | 1454 start, ps1, ps2, &err, &iflags); |
| 1455 if (flags == NULL) { | |
| 1456 localflags.cf_flags = 0; | |
| 1457 flags = &localflags; | |
| 1458 } | |
| 1451 if (n) { | 1459 if (n) { |
| 1452 if (flags) { | 1460 flags->cf_flags |= iflags & PyCF_MASK; |
| 1453 flags->cf_flags |= iflags & PyCF_MASK; | |
| 1454 } | |
| 1455 mod = PyAST_FromNode(n, flags, filename, arena); | 1461 mod = PyAST_FromNode(n, flags, filename, arena); |
| 1456 PyNode_Free(n); | 1462 PyNode_Free(n); |
| 1457 return mod; | 1463 return mod; |
| 1458 } | 1464 } |
| 1459 else { | 1465 else { |
