Message8848
This is now fixed in http://hg.python.org/jython/rev/6cffc2f6a643 (I claim). unicode._formatter_field_name_split is needed as well.
Jython 2.7b3+ (default:5efdcedc9817+6cffc2f6a643+, Jun 29 2014, 15:46:14)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.7.0_60
Type "help", "copyright", "credits" or "license" for more information.
>>> list(u"hello {:{0}d} and {}"._formatter_parser())
[(u'hello ', u'0', u'{0}d', None), (u' and ', u'1', u'', None)]
>>> first, rest = u"a.b[2]"._formatter_field_name_split()
>>> first, list(rest)
(u'a', [(True, u'b'), (False, 2)])
>>> import string
>>> string.Formatter().format(u"{} {:*>12d} {:{width}.{prec}f}", 10, 20, 30, width=8, prec=3)
u'10 **********20 30.000'
>>> string.Formatter().format(u"{0}", 10)
'10'
>>>
The last one is interesting because the problem is in string.py (it produces a str). It happens only if the format contains no literal text at all (just replacement fields) and no unicode arguments:
>>> string.Formatter().format(u"{a}", a=u"b")
u'b'
>>> string.Formatter().format(u"{a}", a="b")
'b'
This appears to be a "won't fix" for CPython. See http://bugs.python.org/issue15951 . |
|
Date |
User |
Action |
Args |
2014-06-29 15:44:18 | jeff.allen | set | messageid: <1404056658.16.0.31839099218.issue2028@psf.upfronthosting.co.za> |
2014-06-29 15:44:18 | jeff.allen | set | recipients:
+ jeff.allen, fwierzbicki, zyasoft, Arfrever, santa4nt, seletz |
2014-06-29 15:44:18 | jeff.allen | link | issue2028 messages |
2014-06-29 15:44:17 | jeff.allen | create | |
|