This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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 ;-)
History
Date User Action Args
2010-03-09 23:44:37vstinnersetrecipients: + vstinner, doerwalter, eric.smith, ezio.melotti, pablomouzo
2010-03-09 23:44:36vstinnersetmessageid: <1268178276.71.0.00644839711154.issue7300@psf.upfronthosting.co.za>
2010-03-09 23:44:34vstinnerlinkissue7300 messages
2010-03-09 23:44:34vstinnercreate