Revision: 8815 Author: xqt Date: 2010-12-31 10:39:50 +0000 (Fri, 31 Dec 2010) Log Message: ----------- raise "Invalid section error" if category page has a section, "speaking" error message for bug #3147994
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2010-12-30 19:19:53 UTC (rev 8814) +++ trunk/pywikipedia/wikipedia.py 2010-12-31 10:39:50 UTC (rev 8815) @@ -376,17 +376,20 @@ break
sectionStart = t.find(u'#') - # Categories does not have sections. # But maybe there are magic words like {{#time|}} # TODO: recognize magic word and templates inside links # see http://la.wikipedia.org/w/index.php?title=997_Priska&diff=prev&oldid... - if sectionStart > 0 and self._namespace not in [14]: - self._section = t[sectionStart+1 : ].lstrip(" ") - self._section = sectionencode(self._section, - self._site.encoding()) - if not self._section: - self._section = None - t = t[ : sectionStart].rstrip(" ") + if sectionStart > 0: + # Categories does not have sections. + if self._namespace == 14: + raise InvalidTitle(u"Invalid section in category '%s'" % t) + else: + self._section = t[sectionStart+1 : ].lstrip(" ") + self._section = sectionencode(self._section, + self._site.encoding()) + if not self._section: + self._section = None + t = t[ : sectionStart].rstrip(" ") elif sectionStart == 0: raise InvalidTitle(u"Invalid title starting with a #: '%s'" % t) else: @@ -2567,8 +2570,9 @@ except NoPage: raise except IsRedirectPage, err: - target = err[0].replace('"', '"') # otherwise it will return error with - # pages with " inside. + # otherwise it will return error pages with " inside. + target = err[0].replace('"', '"') + if '|' in target: warnings.warn("'%s' has a | character, this makes no sense" % target, Warning)
pywikipedia-svn@lists.wikimedia.org