##// END OF EJS Templates
Backport PR #4758 - fixes for Python 3.4.
Thomas Kluyver -
Show More
@@ -15,6 +15,7 b''
15 import os
15 import os
16 import math
16 import math
17 import random
17 import random
18 import sys
18
19
19 import nose.tools as nt
20 import nose.tools as nt
20
21
@@ -107,7 +108,12 b' def eval_formatter_no_slicing_check(f):'
107 s = f.format('{stuff[slice(1,4)]}', **ns)
108 s = f.format('{stuff[slice(1,4)]}', **ns)
108 nt.assert_equal(s, 'ell')
109 nt.assert_equal(s, 'ell')
109
110
110 nt.assert_raises(SyntaxError, f.format, "{a[:]}")
111 if sys.version_info >= (3, 4):
112 # String formatting has changed in Python 3.4, so this now works.
113 s = f.format("{a[:]}", a=[1, 2])
114 nt.assert_equal(s, "[1, 2]")
115 else:
116 nt.assert_raises(SyntaxError, f.format, "{a[:]}")
111
117
112 def test_eval_formatter():
118 def test_eval_formatter():
113 f = text.EvalFormatter()
119 f = text.EvalFormatter()
@@ -509,6 +509,9 b' class EvalFormatter(Formatter):'
509 v = eval(name, kwargs)
509 v = eval(name, kwargs)
510 return v, name
510 return v, name
511
511
512 #XXX: As of Python 3.4, the format string parsing no longer splits on a colon
513 # inside [], so EvalFormatter can handle slicing. Once we only support 3.4 and
514 # above, it should be possible to remove FullEvalFormatter.
512
515
513 @skip_doctest_py3
516 @skip_doctest_py3
514 class FullEvalFormatter(Formatter):
517 class FullEvalFormatter(Formatter):
General Comments 0
You need to be logged in to leave comments. Login now