diff options
author | Benjamin Peterson <benjamin@python.org> | 2012-03-22 12:19:50 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2012-03-22 12:19:50 (GMT) |
commit | 98ba7534322696250267438053fb36cea5b0a85f (patch) | |
tree | 73c4d055f0f2f1d01cbce29adf606c337dc6068e | |
parent | 96ad2619b208ce8452f8f6bd5127f32e2b097d2c (diff) | |
parent | a4e4e35783d26151be19253ff6dd1c3ec2ca7efa (diff) | |
download | cpython-98ba7534322696250267438053fb36cea5b0a85f.zip cpython-98ba7534322696250267438053fb36cea5b0a85f.tar.gz cpython-98ba7534322696250267438053fb36cea5b0a85f.tar.bz2 |
merge 3.2 (#14378)
-rw-r--r-- | Lib/test/test_ast.py | 6 | ||||
-rw-r--r-- | Misc/NEWS | 6 | ||||
-rw-r--r-- | Python/future.c | 10 |
3 files changed, 13 insertions, 9 deletions
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py index 064c669..3b9f10c 100644 --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -226,6 +226,12 @@ class AST_Tests(unittest.TestCase): im = ast.parse("from . import y").body[0] self.assertIsNone(im.module) + def test_non_interned_future_from_ast(self): + mod = ast.parse("from __future__ import division") + self.assertIsInstance(mod.body[0], ast.ImportFrom) + mod.body[0].module = " __future__ ".strip() + compile(mod, "<test>", "exec") + def test_base_classes(self): self.assertTrue(issubclass(ast.For, ast.stmt)) self.assertTrue(issubclass(ast.Name, ast.expr)) @@ -13,7 +13,11 @@ Core and Builtins - Issue #1683368: object.__new__ and object.__init__ raise a TypeError if they are passed arguments and their complementary method is not overridden. -- Give the ast.AST class a __dict__. +- Issue #14378: Fix compiling ast.ImportFrom nodes with a "__future__" string as + the module name that was not interned. + +- Issue #14331: Use significantly less stack space when importing modules by + allocating path buffers on the heap instead of the stack. - Issue #14334: Prevent in a segfault in type.__getattribute__ when it was not passed strings. diff --git a/Python/future.c b/Python/future.c index d6b653f..978dc25 100644 --- a/Python/future.c +++ b/Python/future.c @@ -60,13 +60,6 @@ future_parse(PyFutureFeatures *ff, mod_ty mod, const char *filename) { int i, found_docstring = 0, done = 0, prev_line = 0; - static PyObject *future; - if (!future) { - future = PyUnicode_InternFromString("__future__"); - if (!future) - return 0; - } - if (!(mod->kind == Module_kind || mod->kind == Interactive_kind)) return 1; @@ -93,7 +86,8 @@ future_parse(PyFutureFeatures *ff, mod_ty mod, const char *filename) */ if (s->kind == ImportFrom_kind) { - if (s->v.ImportFrom.module == future) { + PyObject *modname = s->v.ImportFrom.module; + if (!PyUnicode_CompareWithASCIIString(modname, "__future__")) { if (done) { PyErr_SetString(PyExc_SyntaxError, ERR_LATE_FUTURE); |