Patches item #3092870, was opened at 2010-10-22 03:26
Message generated for change (Comment added) made by valhallasw
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=309287…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: lankier (lankier)
Assigned to: xqt (xqt)
Summary: non ascii in system messages and max retry
Initial Comment:
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.
----------------------------------------------------------------------
Comment By: Merlijn S. van Deen (valhallasw)
Date: 2012-03-21 09:49
Message:
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.
----------------------------------------------------------------------
Comment By: lankier (lankier)
Date: 2010-11-07 12:44
Message:
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.
----------------------------------------------------------------------
Comment By: xqt (xqt)
Date: 2010-11-07 08:52
Message:
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())
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=309287…