https://bugzilla.wikimedia.org/show_bug.cgi?id=54572
Web browser: --- Bug ID: 54572 Summary: non ascii in system messages and max retry Product: Pywikibot Version: unspecified Hardware: All OS: All Status: ASSIGNED Severity: normal Priority: Unprioritized Component: General Assignee: Pywikipedia-bugs@lists.wikimedia.org Reporter: legoktm.wikipedia@gmail.com Classification: Unclassified Mobile Platform: ---
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] Сеть недоступна> WARNING: Could not open [...]
2. Added raise MaxTriesExceededError when max tries exceeded.
https://bugzilla.wikimedia.org/show_bug.cgi?id=54572
--- Comment #1 from Kunal Mehta (Legoktm) legoktm.wikipedia@gmail.com --- We can't fix it in output() because we have an exception before we entered in output().
What about just replace output(u'%s' %e) -> output(str(e)) ? it works.
https://bugzilla.wikimedia.org/show_bug.cgi?id=54572
--- Comment #2 from Kunal Mehta (Legoktm) legoktm.wikipedia@gmail.com --- output should be fixed in output method. Would you please check the following fix in output method:
def output(...) ... try: text = unicode(text, 'utf-8') except UnicodeDecodeError: text = unicode(text, 'iso8859-1')
replace it with
try: text = unicode(text, 'utf-8') except UnicodeDecodeError: text = unicode(text, locale.getpreferredencoding())
https://bugzilla.wikimedia.org/show_bug.cgi?id=54572
--- Comment #3 from Kunal Mehta (Legoktm) legoktm.wikipedia@gmail.com --- I think we should either a) skip the entire output() machinery and use traceback.print_exc() instead or b) write a wrapper for that does what you propose here (but which can also be used for traceback.format_exc).
and replace all exception printing with one of those two options.
https://bugzilla.wikimedia.org/show_bug.cgi?id=54572
--- Comment #4 from Kunal Mehta (Legoktm) legoktm.wikipedia@gmail.com --- housekeeper's note: the patch does not apply cleanly to r10035
https://bugzilla.wikimedia.org/show_bug.cgi?id=54572
--- Comment #5 from Kunal Mehta (Legoktm) legoktm.wikipedia@gmail.com --- - **status**: pending --> open
https://bugzilla.wikimedia.org/show_bug.cgi?id=54572
--- Comment #6 from Kunal Mehta (Legoktm) legoktm.wikipedia@gmail.com --- - **status**: open --> pending
https://bugzilla.wikimedia.org/show_bug.cgi?id=54572
--- Comment #7 from Kunal Mehta (Legoktm) legoktm.wikipedia@gmail.com --- - **assigned_to**: nobody --> xqt
https://bugzilla.wikimedia.org/show_bug.cgi?id=54572
Kunal Mehta (Legoktm) legoktm.wikipedia@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://sourceforge.net/p/p | |ywikipediabot/patches/477
https://bugzilla.wikimedia.org/show_bug.cgi?id=54572
xqt info@gno.de changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |NEW CC| |info@gno.de
https://bugzilla.wikimedia.org/show_bug.cgi?id=54572
John Mark Vandenberg jayvdb@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Version|unspecified |compat (1.0) Assignee|Pywikipedia-bugs@lists.wiki |info@gno.de |media.org |
pywikipedia-bugs@lists.wikimedia.org