STINNER Victor <[email protected]> added the comment:
*Draft* patch fixing the issue: render_field() raises an error if the argument
is an unicode argument, string_format() catchs this error and converts self to
unicode and call unicode.format(*args, **kw).
Pseudo-code:
try:
# self.format() raises an error if any argument is
# an unicode string)
return self.format(*args,**kw)
except UnicodeError:
unicode = self.decode(default_encoding)
return unicode.format(*args, **kw)
The patch changes the result type of '{}'.format(u'ascii'): it was str and it
becomes unicode. The new behaviour is consistent with "%s" % u"ascii" =>
u"ascii" (unicode).
I'm not sure that catching *any* unicode error is a good idea. I think that it
would be better to use a new exception type dedicated to this issue, but it
looks complex to define a new exception. I will may do it for the next patch
version ;-)
----------
keywords: +patch
Added file: http://bugs.python.org/file16514/issue7300-trunk.patch
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue7300>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com