Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a4e4e357
Commit
a4e4e357
authored
Mar 22, 2012
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check by equality for __future__ not identity (closes #14378)
parent
e1121537
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
8 deletions
+11
-8
Lib/test/test_ast.py
Lib/test/test_ast.py
+6
-0
Misc/NEWS
Misc/NEWS
+3
-0
Python/future.c
Python/future.c
+2
-8
No files found.
Lib/test/test_ast.py
View file @
a4e4e357
...
...
@@ -218,6 +218,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
))
...
...
Misc/NEWS
View file @
a4e4e357
...
...
@@ -10,6 +10,9 @@ What's New in Python 3.2.4
Core and Builtins
-----------------
- 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.
...
...
Python/future.c
View file @
a4e4e357
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment