Last modified: 2014-09-18 09:29:36 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T56572, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 54572 - non ascii in system messages and max retry
non ascii in system messages and max retry
Status: NEW
Product: Pywikibot
Classification: Unclassified
General (Other open bugs)
compat-(1.0)
All All
: Unprioritized normal
: ---
Assigned To: xqt
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-09-24 22:35 UTC by Kunal Mehta (Legoktm)
Modified: 2014-09-18 09:29 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Kunal Mehta (Legoktm) 2013-09-24 22:35:52 UTC
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.
Comment 1 Kunal Mehta (Legoktm) 2013-09-24 22:35:55 UTC
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 2 Kunal Mehta (Legoktm) 2013-09-24 22:35:57 UTC
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\(\)\)
Comment 3 Kunal Mehta (Legoktm) 2013-09-24 22:35:59 UTC
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 4 Kunal Mehta (Legoktm) 2013-09-24 22:36:00 UTC
housekeeper's note: the patch does not apply cleanly to r10035
Comment 5 Kunal Mehta (Legoktm) 2013-09-24 22:36:02 UTC
- **status**: pending --> open
Comment 6 Kunal Mehta (Legoktm) 2013-09-24 22:36:04 UTC
- **status**: open --> pending
Comment 7 Kunal Mehta (Legoktm) 2013-09-24 22:36:06 UTC
- **assigned_to**: nobody --> xqt

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links