Revision: 6801 Author: nicdumz Date: 2009-05-03 08:54:27 +0000 (Sun, 03 May 2009)
Log Message: ----------- Pages such as #redirect [[cs:#foo]] raise InvalidTitle. Catch the error, and ignore the page
Modified Paths: -------------- trunk/pywikipedia/interwiki.py
Modified: trunk/pywikipedia/interwiki.py =================================================================== --- trunk/pywikipedia/interwiki.py 2009-05-03 08:52:16 UTC (rev 6800) +++ trunk/pywikipedia/interwiki.py 2009-05-03 08:54:27 UTC (rev 6801) @@ -1073,7 +1073,13 @@ continue
elif page.isRedirectPage(): - redirectTargetPage = page.getRedirectTarget() + try: + redirectTargetPage = page.getRedirectTarget() + except wikipedia.InvalidTitle: + # MW considers #redirect [[en:#foo]] as a redirect page, + # but we can't do anything useful with such pages + wikipedia.output(u"NOTE: %s redirects to an invalid title" % page.aslink(True)) + continue wikipedia.output(u"NOTE: %s is redirect to %s" % (page.aslink(True), redirectTargetPage.aslink(True))) if page == self.originPage: if globalvar.initialredirect:
pywikipedia-svn@lists.wikimedia.org