Originally from: http://sourceforge.net/p/pywikipediabot/patches/477/
Reported by: lankier
Created on: 2010-10-22 10:26:44
Subject: non ascii in system messages and max retry
Assigned to: xqt
Original description:
This patch fixed two issues:
1\. Ubuntu has non ascii in system messages.
Test:
$ sudo ifconfig eth0 down
$ cat test.py
import wikipedia
site = wikipedia.getSite\(\)
page = wikipedia.Page\(site, 'S'\)
text = page.get\(\)
$ LANG=ru\_RU.utf8 python test.py
Error downloading data: 'ascii' codec can't decode byte 0xd0 in position 27: ordinal not in range\(128\)
Request ru:/w/api.php?inprop=protection%7Ctalkid%7Csubjectid%7Curl%7Creadable&format=json&rvprop=content%7Cids%7Cflags%7Ctimestamp%7Cuser%7Ccomment%7Csize&prop=revisions%7Cinfo&titles=S&rvlimit=1&action=query
Retrying in 1 minutes...
^C
After fix \(added "e = unicode\(str\(e\), locale.getpreferredencoding\(\)\)"\):
$ LANG=ru\_RU.utf8 python test.py
<urlopen error \[Errno 101\] Сеть недоступна>
2\. Added raise MaxTriesExceededError when max tries exceeded.
Version: compat-(1.0)
Severity: normal
See Also:
https://sourceforge.net/p/pywikipediabot/patches/477