-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hello all!
I got this error (from trunk):
Traceback (most recent call last): File "../pywikipedia/subster.py", line 251, in subContent (substed_content, tags) = self.subTemplate(substed_content, item) File "../pywikipedia/subster.py", line 345, in subTemplate external_buffer = http.request(self.site, param['url'], no_hostname = True) File "../pywikipedia/pywikibot/comms/http.py", line 125, in request pywikibot.output(u'%s' %e) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 42: ordinal not in range(128)
and was able to trace the code line 125 (http.py): pywikibot.output(u'%s' %e)
back to "revision 7591 by alexsh, Wed Nov 4 13:22:17 2009 UTC" line 5508, please confer [1]. Now this code snipplet is quite old and I doubt someone is able to remember any details... ;)
[1] http://svn.wikimedia.org/viewvc/pywikipedia/trunk/pywikipedia/wikipedia.py?r...
...BUT what about the error I got? Does anybody experience the same? I think it is related to network timeouts (e.g. servers not reachable) and thus hard to reproduce...
I was using Python 2.7.3: Python 2.7.3 (default, May 29 2012, 14:54:22) [GCC 4.6.3 20120306 (Red Hat 4.6.3-2)] on linux2
Greetings and thanks for any hints! DrTrigon
On 22 June 2012 17:13, Dr. Trigon dr.trigon@surfeu.ch wrote:
...BUT what about the error I got? Does anybody experience the same? I think it is related to network timeouts (e.g. servers not reachable) and thus hard to reproduce...
My guess: you are running a German Windows version, which will give you a German error message, with non-ASCII characters, when the connection fails. This error message is encoded in the latin-1 ('western european') encoding, and decoding it as plain ascii fails. Feel free to substitute German for French, Spanish or any other language that might have non-ascii error messages.
We should probably decode it using the current console encoding, but it's not really clear to me what the pitfalls would be.
Merlijn
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 23.06.2012 00:03, Merlijn van Deen wrote:
My guess: you are running a German Windows version, which will give you a German error message, with non-ASCII characters, when the
I would *NEVER EVER* use windows...(!) ;)))
connection fails. This error message is encoded in the latin-1 ('western european') encoding, and decoding it as plain ascii fails. Feel free to substitute German for French, Spanish or any other language that might have non-ascii error messages.
Regarding the language you might be right, using 'locale' gives me some non-standard locale. So how to get the english (decodable as ascii) original/default message? If I would know the error raised, I could check the error message for problematic chars and try to avoid this...
We should probably decode it using the current console encoding, but it's not really clear to me what the pitfalls would be.
Would a 'locale.setlocale(locale.LC_ALL, 'en_US')' in front of the problematic output help at all?
Thank for your answer! Greetings DrTrigon
2012/6/23 Merlijn van Deen valhallasw@arctus.nl
My guess: you are running a German Windows version, which will give you a German error message, with non-ASCII characters, when the connection fails. This error message is encoded in the latin-1 ('western european') encoding, and decoding it as plain ascii fails. Feel free to substitute German for French, Spanish or any other language that might have non-ascii error messages.
Is this the same as http://sourceforge.net/tracker/?func=detail&aid=3153555&group_id=931... This is an old problem. Once I tried to deal with that but could not reproduce the error on purpose. How to create a test environment for such network errors?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Is this the same as http://sourceforge.net/tracker/?func=detail&aid=3153555&group_id=931...
?
This is an old problem. Once I tried to deal with that but could not
Yes it is this problem, thanks for mentioning it!!
reproduce the error on purpose. How to create a test environment for such network errors?
Exactly THAT is the point!! ;) Since the output of the exception does not work it is close to impossible to reproduce this. I was thinking about a clean way of forcing the error... but as mentioned in the very first mail "I think it is related to network timeouts" - may be just pulling the plug while waiting for answer on a network request would do that job... but as you see it is no nice 'reproduction'... ;))
Would the mentioned code 'output(u"%r"% e)' print the object for sure? Is it known to avoid those errors or was it just an assumption? If it is known (for sure) to help then I would suggest to change to:
output(u"%r"% e) output(u"%s" % e)
in order to get hints about the issue in the future.
Greetings DrTrigon
pywikipedia-l@lists.wikimedia.org