Last modified: 2013-11-12 21:23:45 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T58873, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 56873 - Category.isCategoryRedirect() does not work on wikis without category redirect template defined in family file
Category.isCategoryRedirect() does not work on wikis without category redirec...
Status: RESOLVED FIXED
Product: Pywikibot
Classification: Unclassified
General (Other open bugs)
core-(2.0)
All All
: Unprioritized blocker
: ---
Assigned To: Pywikipedia bugs
:
Depends on:
Blocks: 56774
  Show dependency treegraph
 
Reported: 2013-11-10 18:24 UTC by pyfisch
Modified: 2013-11-12 21:23 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Proposed patch (2.29 KB, patch)
2013-11-10 18:58 UTC, Strainu
Details

Description pyfisch 2013-11-10 18:24:20 UTC
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')
>>> cat.isCategoryRedirect()
de _default
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/pywikibot/page.py", line 471, in isCategoryRedirect
    catredirs = self.site.category_redirects()
  File "/usr/lib/python2.7/pywikibot/site.py", line 223, in <lambda>
    f = lambda *args, **kwargs: method(self.code, *args, **kwargs)
  File "/usr/lib/python2.7/pywikibot/family.py", line 864, in category_redirects
    self.get_cr_templates(code, fallback)
  File "/usr/lib/python2.7/pywikibot/family.py", line 879, in get_cr_templates
    cr_template = self.category_redirect_templates[fallback][0]
IndexError: tuple index out of range
>>> 

This bug is blocking https://bugzilla.wikimedia.org/show_bug.cgi?id=56774
Comment 1 Strainu 2013-11-10 18:58:13 UTC
Created attachment 13758 [details]
Proposed patch

Here is a proposed solution. It also fixes fringe case when the language exists, but is empty.
Comment 2 Strainu 2013-11-10 19:01:16 UTC
I experimented with the gerrit patch uploader, but apparently the change cannot be merged automatically.

https://gerrit.wikimedia.org/r/#/c/94621/
Comment 3 Gerrit Notification Bot 2013-11-12 17:15:12 UTC
Change 94621 had a related patch set uploaded by Xqt:
Fix access to the fallback category redirect list.

https://gerrit.wikimedia.org/r/94621
Comment 4 Gerrit Notification Bot 2013-11-12 21:22:35 UTC
Change 94621 merged by jenkins-bot:
[Bug 56873] Fix access to the fallback category redirect list.

https://gerrit.wikimedia.org/r/94621

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links