Message100770
*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 ;-) |
|
Date |
User |
Action |
Args |
2010-03-09 23:44:37 | vstinner | set | recipients:
+ vstinner, doerwalter, eric.smith, ezio.melotti, pablomouzo |
2010-03-09 23:44:36 | vstinner | set | messageid: <1268178276.71.0.00644839711154.issue7300@psf.upfronthosting.co.za> |
2010-03-09 23:44:34 | vstinner | link | issue7300 messages |
2010-03-09 23:44:34 | vstinner | create | |
|