Page MenuHomePhabricator

Category.isCategoryRedirect() does not work on wikis without category redirect template defined in family file
Closed, ResolvedPublic


Author: pyfisch

If you call isCategoryRedirect on a category which is from a wiki which has no category redirect templates defined in the family file an error occurs.

user@computer:~$ python
Python 2.7.5+ (default, Sep 19 2013, 13:48:49)
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import pywikibot
site = pywikibot.Site('de', 'wikipedia')
cat = pywikibot.Category(site, 'Category:Hannover')

de _default
Traceback (most recent call last):

File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/pywikibot/", line 471, in isCategoryRedirect
  catredirs =
File "/usr/lib/python2.7/pywikibot/", line 223, in <lambda>
  f = lambda *args, **kwargs: method(self.code, *args, **kwargs)
File "/usr/lib/python2.7/pywikibot/", line 864, in category_redirects
  self.get_cr_templates(code, fallback)
File "/usr/lib/python2.7/pywikibot/", line 879, in get_cr_templates
  cr_template = self.category_redirect_templates[fallback][0]

IndexError: tuple index out of range

This bug is blocking

Version: core-(2.0)
Severity: blocker



Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 2:26 AM
bzimport set Reference to bz56873.
bzimport added a subscriber: Unknown Object (????).

Created attachment 13758
Proposed patch

Here is a proposed solution. It also fixes fringe case when the language exists, but is empty.


I experimented with the gerrit patch uploader, but apparently the change cannot be merged automatically.

Change 94621 had a related patch set uploaded by Xqt:
Fix access to the fallback category redirect list.

Change 94621 merged by jenkins-bot:
[Bug 56873] Fix access to the fallback category redirect list.