Re: Unicode bug in % operation (and patch)
Neil Schemenauer <[email protected]>
| Newsgroups | gmane.comp.web.quixote.user |
|---|---|
| Message-ID | <[email protected]> |
Alexander J. Kozlovsky <[email protected]> wrote: > I'm sorry for my bad English. My native language is Russian, and I > write English very bad No, your English is quite good. > I propose patch. I think, this patch solves all above-mentioned > problems. It may solve the above mentioned problems but it doesn't solve this very annoying problem: >>> from quixote.html import htmltext >>> htmltext('string %s') % u'\u1234' Traceback (most recent call last): File "<stdin>", line 1, in ? UnicodeEncodeError: 'ascii' codec can't encode character u'\u1234' in position 0: ordinal not in range(128) The true problem lies in Python's str.__mod__ method. I've fixed it for Python 2.5. With the CVS version of Python, the current version of Quixote produces the output you expect. That said, your patch does somewhat improve the situation. As I understand it, it fixes this case: >>> htmltext('string %s') % htmltext(u'\u1234') <htmltext u'string \u1234'> With the current Quixote you will get a UnicodeEncodeError. Thanks for your feedback, Neil