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
bdca942f
Commit
bdca942f
authored
Oct 26, 2008
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix __future__ imports when multiple features are given
parent
adc93b94
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
5 deletions
+9
-5
Lib/test/test_future.py
Lib/test/test_future.py
+6
-2
Misc/NEWS
Misc/NEWS
+3
-0
Parser/parser.c
Parser/parser.c
+0
-3
No files found.
Lib/test/test_future.py
View file @
bdca942f
...
@@ -89,19 +89,23 @@ class FutureTest(unittest.TestCase):
...
@@ -89,19 +89,23 @@ class FutureTest(unittest.TestCase):
# the parser hack disabled. If a new keyword is introduced in
# the parser hack disabled. If a new keyword is introduced in
# 2.6, change this to refer to the new future import.
# 2.6, change this to refer to the new future import.
try:
try:
exec "
from
__future__
import
division
,
with_statement
;
with
=
0
"
exec "
from
__future__
import
print_function
;
print
0
"
except SyntaxError:
except SyntaxError:
pass
pass
else:
else:
self.fail("
syntax
error
didn
't occur")
self.fail("
syntax
error
didn
't occur")
try:
try:
exec "from __future__ import (
with_statement, division); with =
0"
exec "from __future__ import (
print_function); print
0"
except SyntaxError:
except SyntaxError:
pass
pass
else:
else:
self.fail("syntax error didn'
t
occur
")
self.fail("syntax error didn'
t
occur
")
def test_multiple_features(self):
test_support.unload("
test
.
test_future5
")
from test import test_future5
def test_main():
def test_main():
test_support.run_unittest(FutureTest)
test_support.run_unittest(FutureTest)
...
...
Misc/NEWS
View file @
bdca942f
...
@@ -12,6 +12,9 @@ What's New in Python 2.7 alpha 1
...
@@ -12,6 +12,9 @@ What's New in Python 2.7 alpha 1
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #4209: Enabling unicode_literals and the print_function in the same
__future__ import didn't work.
- Using ``nonlocal`` as a variable name will now raise a Py3k SyntaxWarning
- Using ``nonlocal`` as a variable name will now raise a Py3k SyntaxWarning
because it is a reserved word in 3.x.
because it is a reserved word in 3.x.
...
...
Parser/parser.c
View file @
bdca942f
...
@@ -206,13 +206,10 @@ future_hack(parser_state *ps)
...
@@ -206,13 +206,10 @@ future_hack(parser_state *ps)
char
*
str_ch
=
STR
(
CHILD
(
cch
,
0
));
char
*
str_ch
=
STR
(
CHILD
(
cch
,
0
));
if
(
strcmp
(
str_ch
,
FUTURE_WITH_STATEMENT
)
==
0
)
{
if
(
strcmp
(
str_ch
,
FUTURE_WITH_STATEMENT
)
==
0
)
{
ps
->
p_flags
|=
CO_FUTURE_WITH_STATEMENT
;
ps
->
p_flags
|=
CO_FUTURE_WITH_STATEMENT
;
break
;
}
else
if
(
strcmp
(
str_ch
,
FUTURE_PRINT_FUNCTION
)
==
0
)
{
}
else
if
(
strcmp
(
str_ch
,
FUTURE_PRINT_FUNCTION
)
==
0
)
{
ps
->
p_flags
|=
CO_FUTURE_PRINT_FUNCTION
;
ps
->
p_flags
|=
CO_FUTURE_PRINT_FUNCTION
;
break
;
}
else
if
(
strcmp
(
str_ch
,
FUTURE_UNICODE_LITERALS
)
==
0
)
{
}
else
if
(
strcmp
(
str_ch
,
FUTURE_UNICODE_LITERALS
)
==
0
)
{
ps
->
p_flags
|=
CO_FUTURE_UNICODE_LITERALS
;
ps
->
p_flags
|=
CO_FUTURE_UNICODE_LITERALS
;
break
;
}
}
}
}
}
}
...
...
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