Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9aebc61

Browse files
committed
Merged revisions 67030-67031 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r67030 | benjamin.peterson | 2008-10-26 15:21:13 -0500 (Sun, 26 Oct 2008) | 1 line fix __future__ imports when multiple features are given ........ r67031 | benjamin.peterson | 2008-10-26 15:33:19 -0500 (Sun, 26 Oct 2008) | 1 line add forgotten test for r67030 ........
1 parent cff882c commit 9aebc61

3 files changed

Lines changed: 27 additions & 5 deletions

File tree

Lib/test/test_future.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,23 @@ def test_parserhack(self):
8989
# the parser hack disabled. If a new keyword is introduced in
9090
# 2.6, change this to refer to the new future import.
9191
try:
92-
exec("from __future__ import division, with_statement; with = 0")
92+
exec("from __future__ import print_function; print 0")
9393
except SyntaxError:
9494
pass
9595
else:
9696
self.fail("syntax error didn't occur")
9797

9898
try:
99-
exec("from __future__ import (with_statement, division); with = 0")
99+
exec("from __future__ import (print_function); print 0")
100100
except SyntaxError:
101101
pass
102102
else:
103103
self.fail("syntax error didn't occur")
104104

105+
def test_multiple_features(self):
106+
support.unload("test.test_future5")
107+
from test import test_future5
108+
105109

106110
def test_main():
107111
support.run_unittest(FutureTest)

Lib/test/test_future5.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Check that multiple features can be enabled.
2+
from __future__ import unicode_literals, print_function
3+
4+
import sys
5+
import unittest
6+
from . import support
7+
8+
9+
class TestMultipleFeatures(unittest.TestCase):
10+
11+
def test_unicode_literals(self):
12+
self.assertTrue(isinstance("", str))
13+
14+
def test_print_function(self):
15+
with support.captured_output("stderr") as s:
16+
print("foo", file=sys.stderr)
17+
self.assertEqual(s.getvalue(), "foo\n")
18+
19+
20+
def test_main():
21+
support.run_unittest(TestMultipleFeatures)

Parser/parser.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,10 @@ future_hack(parser_state *ps)
210210
char *str_ch = STR(CHILD(cch, 0));
211211
if (strcmp(str_ch, FUTURE_WITH_STATEMENT) == 0) {
212212
ps->p_flags |= CO_FUTURE_WITH_STATEMENT;
213-
break;
214213
} else if (strcmp(str_ch, FUTURE_PRINT_FUNCTION) == 0) {
215214
ps->p_flags |= CO_FUTURE_PRINT_FUNCTION;
216-
break;
217215
} else if (strcmp(str_ch, FUTURE_UNICODE_LITERALS) == 0) {
218216
ps->p_flags |= CO_FUTURE_UNICODE_LITERALS;
219-
break;
220217
}
221218
}
222219
}

0 commit comments

Comments
 (0)