Revision: 5391 Author: nicdumz Date: 2008-05-17 14:21:52 +0000 (Sat, 17 May 2008)
Log Message: ----------- * Bug #1965938 "Article 'Loyalit?\195?\164t' in de.wikt throws UTF decoding exception" : That article contained an invalid template, {{Loyalit%E4t}}, and it appears that incorrect template names were not handled correctly. Indeed, "except Error" does not catch _ALL_ Errors. "except Exception", or "except:" is needed if you want to catch UnicodeDecodeError
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2008-05-17 11:53:49 UTC (rev 5390) +++ trunk/pywikipedia/wikipedia.py 2008-05-17 14:21:52 UTC (rev 5391) @@ -1736,7 +1736,7 @@ continue try: name = Page(self.site(), name).title() - except Error: + except: if name.strip(): output( u"Page %s contains invalid template name {{%s}}."
Am Samstag 17 Mai 2008 schrieb nicdumz@svn.wikimedia.org:
Revision: 5391
- Bug #1965938 "Article 'Loyalit?\195?\164t' in de.wikt throws UTF decoding
exception" : That article contained an invalid template, {{Loyalit%E4t}}, and it appears that incorrect template names were not handled correctly. Indeed, "except Error" does not catch _ALL_ Errors. "except Exception", or "except:" is needed if you want to catch UnicodeDecodeError
except Error:
except:
Hi nicdumz,
please be careful when writing such stuff. If you just write except, you also catch KeyboardInterrupt. But if you catch it, the user can no longer press CTRL-C to interrupt the script.
See: http://effbot.org/zone/stupid-exceptions-keyboardinterrupt.htm
Cheers
Daniel
ah, sure. I honestly did not think of a KeyboardInterrupt, but I thought that catching all exceptions no matter what was strange when you know the exact exception you want to catch, and that's why I rewrote my fix in r5392.
Thanks for this precision, I learned something new :)
2008/5/18 Daniel Herding DHerding@gmx.de:
Am Samstag 17 Mai 2008 schrieb nicdumz@svn.wikimedia.org:
Revision: 5391
- Bug #1965938 "Article 'Loyalit?\195?\164t' in de.wikt throws UTF decoding
exception" : That article contained an invalid template, {{Loyalit%E4t}}, and it appears that incorrect template names were not handled correctly. Indeed, "except Error" does not catch _ALL_ Errors. "except Exception", or "except:" is needed if you want to catch UnicodeDecodeError
except Error:
except:
Hi nicdumz,
please be careful when writing such stuff. If you just write except, you also catch KeyboardInterrupt. But if you catch it, the user can no longer press CTRL-C to interrupt the script.
See: http://effbot.org/zone/stupid-exceptions-keyboardinterrupt.htm
Cheers
Daniel
Pywikipedia-l mailing list Pywikipedia-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l