Comment 9 for bug 525901

Revision history for this message
R. David Murray (rdmurray) wrote :

I don't think issue 2522 has anything to do with the reported problem. That issue dealt with someone calling locale.format in an inappropriate way, and the fix disallows the inappropriate call. The call in the traceback is appropriate, so the fix from 2522 should not affect the code having the problem.

This problem is instead related to this issue: http://bugs.python.org/issue7327. The root problem is that python2's float formatting machinery doesn't know now to handle the Czech no-break-space, which is a multibyte charater. It returns it as if it were normal ascii codepoints, but it isn't. So when 'unicode' tries to convert the presumed ASCII string to unicode, it fails.

As noted in the issue, this isn't going to get fixed in python2. It could be worked around in the code that is using grouping=True by doing this:

      locale.format("%d", val, grouping=True).decode(locale.getpreferredencoding())