[Pywikipedia-l] Bug fix for userlib.User.__str__

Dr. Trigon dr.trigon at surfeu.ch
Sun Sep 19 11:15:44 UTC 2010


Hello all

I recognized an issue, when executing the following code:

print userlib.User(pywikibot.getSite(), u'º_the_Bench_º')

results in

Traceback (most recent call last):
   File "tests/dtbext_tester.py", line 279, in <module>
     print userlib.User(pywikibot.getSite(), u'º_the_Bench_º')
UnicodeEncodeError: 'ascii' codec can't encode character u'\xba' in 
position 13: ordinal not in range(128)

The u'\xba' is assigned to u'º' which raises an UnicodeEncodeError.

By using the patch attached, which simply adds an
'.encode(self.site().encoding())' to the string produced the issues
is solved for me. And produces:

wikipedia:de:º_the_Bench_º

May be the 'self.site().encoding()' should or has to be replaced by
another var or const. But the encoding to something like 'utf8' is
essential as statet in [1].

Thanks a lot and greetings
DrTrigon


[1] http://wiki.python.org/moin/UnicodeEncodeError

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch.diff
Url: http://lists.wikimedia.org/pipermail/pywikipedia-l/attachments/20100919/9c2d055a/attachment.txt 


More information about the Pywikipedia-l mailing list