Message100770
| Author |
vstinner |
| Recipients |
doerwalter, eric.smith, ezio.melotti, pablomouzo, vstinner |
| Date |
2010年03月09日.23:44:31 |
| SpamBayes Score |
6.6651e-10 |
| Marked as misclassified |
No |
| Message-id |
<1268178276.71.0.00644839711154.issue7300@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
*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 ;-) |
|