Comment 4 for bug 276884

Revision history for this message
Michael Terry (mterry) wrote :

I've been looking at this. The fix Kyle suggested does help, but as Tim pointed out, doesn't solve the root problem. You still won't be able to print with such a printer (or at least, I couldn't).

The root problem is that the Python lower() method on strings is locale-dependent. When _expand_flags tries to assign attributes, it converts uppercase strings to lowercase attributes. In the Turkish locale, the letter I (eye) is not lowercased, resulting in attributes like 'rejectIng'. This causes problems all over the place.

Background on this can be seen in this thread: http://mail.python.org/pipermail/python-list/2008-January/644769.html and in the Unicode spec, section 5.18.

You can test that this crazy situation is true by the following commands:

$ LANG=en_US.UTF-8 python -c "import locale; locale.setlocale(locale.LC_ALL, ''); print 'TURKISH'.lower()"
turkish
$ LANG=tr_TR.UTF-8 python -c "import locale; locale.setlocale(locale.LC_ALL, ''); print 'TURKISH'.lower()"
turkIsh

What is really wanted is a non-locale-dependent 'lower' function here, which Python apparently does not provide. It's simple to write, but I'm surprised it's not already there.

I've made that change in the code and I *still* can't get it to print, but at least I'm not seeing exceptions. I'm still investigating, but it may be more lower()/upper() goofiness.