cpython: 9d793be3b4eb (original) (raw)
Mercurial > cpython
changeset 75869:9d793be3b4eb
merge 3.2 (#14378) [#14378]
Benjamin Peterson benjamin@python.org | |
---|---|
date | Thu, 22 Mar 2012 08:19:50 -0400 |
parents | 7c52a59f1409(current diff)f57cbcefde34(diff) |
children | db154e62ac03 |
files | Lib/test/test_ast.py Misc/NEWS |
diffstat | 3 files changed, 13 insertions(+), 9 deletions(-)[+] [-] Lib/test/test_ast.py 6 Misc/NEWS 6 Python/future.c 10 |
line wrap: on
line diff
--- 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")[](#l1.8)
self.assertIsInstance(mod.body[0], ast.ImportFrom)[](#l1.9)
mod.body[0].module = " __future__ ".strip()[](#l1.10)
compile(mod, "<test>", "exec")[](#l1.11)
+ def test_base_classes(self): self.assertTrue(issubclass(ast.For, ast.stmt)) self.assertTrue(issubclass(ast.Name, ast.expr))
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -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.
--- a/Python/future.c +++ b/Python/future.c @@ -60,13 +60,6 @@ future_parse(PyFutureFeatures *ff, mod_t { int i, found_docstring = 0, done = 0, prev_line = 0;
- static PyObject *future;
- if (!future) {
future = PyUnicode_InternFromString("__future__");[](#l3.9)
if (!future)[](#l3.10)
return 0;[](#l3.11)
- }
- if (!(mod->kind == Module_kind || mod->kind == Interactive_kind)) return 1; @@ -93,7 +86,8 @@ future_parse(PyFutureFeatures *ff, mod_t */ if (s->kind == ImportFrom_kind) {
if (s->v.ImportFrom.module == future) {[](#l3.21)
PyObject *modname = s->v.ImportFrom.module;[](#l3.22)
if (!PyUnicode_CompareWithASCIIString(modname, "__future__")) {[](#l3.23) if (done) {[](#l3.24) PyErr_SetString(PyExc_SyntaxError,[](#l3.25) ERR_LATE_FUTURE);[](#l3.26)