Fix unicode handling issue of utils.str.format on Python 2.

This commit is contained in:
Valentin Lorentz 2014-07-31 19:57:14 +02:00
parent 7057112d2d
commit 8be1671867

View File

@ -448,6 +448,13 @@ def format(s, *args, **kwargs):
# to add the character to the _formatRe regexp or it will be ignored
# (and hard to debug if you don't know the trick).
# Of course, you should also document it in the docstring above.
if sys.version_info.major < 3:
def pred(s):
if isinstance(s, unicode):
return s.encode('utf8')
else:
return s
args = map(pred, args)
args = list(args)
args.reverse() # For more efficient popping.
def sub(match):