Skip to content
This repository was archived by the owner on Mar 23, 2023. It is now read-only.

Commit d819a44

Browse files
authored
Implement future unicode_literals. (#286)
1 parent 6ec81e8 commit d819a44

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

compiler/imputil.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,11 @@ def _script_exists(self, dirname, name):
180180
'unicode_literals',
181181
)
182182

183-
_IMPLEMENTED_FUTURE_FEATURES = ('absolute_import', 'print_function',)
183+
_IMPLEMENTED_FUTURE_FEATURES = (
184+
'absolute_import',
185+
'print_function',
186+
'unicode_literals'
187+
)
184188

185189
# These future features are already in the language proper as of 2.6, so
186190
# importing them via __future__ has no effect.

compiler/imputil_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,6 @@ def testImportFromFutureParseError(self):
279279
# by grumpy
280280
('from __future__ import division',
281281
r'future feature \w+ not yet implemented'),
282-
('from __future__ import unicode_literals',
283-
r'future feature \w+ not yet implemented'),
284282
('from __future__ import braces', 'not a chance'),
285283
('from __future__ import nonexistant_feature',
286284
r'future feature \w+ is not defined'),

compiler/stmt_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,12 @@ def testImportFutureLateRaises(self):
303303
self.assertRaisesRegexp(util.ImportError, regexp, _ParseAndVisit,
304304
'foo = bar\nfrom __future__ import print_function')
305305

306+
def testFutureUnicodeLiterals(self):
307+
want = "u'foo'\n"
308+
self.assertEqual((0, want), _GrumpRun(textwrap.dedent("""\
309+
from __future__ import unicode_literals
310+
print repr('foo')""")))
311+
306312
def testImportMember(self):
307313
self.assertEqual((0, "<type 'dict'>\n"), _GrumpRun(textwrap.dedent("""\
308314
from sys import modules

0 commit comments

Comments
 (0)