Last modified: 2014-10-22 07:07:23 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 T74344, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 72344 - Page.previousRevision exception
Page.previousRevision exception
Status: RESOLVED WORKSFORME
Product: Pywikibot
Classification: Unclassified
General (Other open bugs)
core-(2.0)
All All
: Unprioritized critical
: ---
Assigned To: Pywikipedia bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-10-22 06:00 UTC by John Mark Vandenberg
Modified: 2014-10-22 07:07 UTC (History)
0 users

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


Attachments

Description John Mark Vandenberg 2014-10-22 06:00:20 UTC
Page.previousRevision assumes many revisions are loaded by Page.getVersionHistory.

$ python pwb.py shell
Welcome to the Pywikibot interactive shell!
>>> import pywikibot
>>> s = pywikibot.Site('en', 'wikipedia')
>>> p = pywikibot.Page(s, 'Main Page')
>>> p.previousRevision()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File ".../pywikibot/page.py", line 550, in previousRevision
    revkey = sorted(self._revisions, reverse=True)[1]
IndexError: list index out of range

Page.getVersionHistory loads all revisions only if total is not set, but if total is set, it only fetches one revision.

>>> p = pywikibot.Page(s, 'Main Page')
>>> p.getVersionHistory()
[(615503846, Timestamp(2014, 7, 4, 0, 24, 48), u'Magioladitis', u'Reverted edits by [[Special:Contribs/Magioladitis|Magioladitis]] ([[User talk:Magioladitis|talk]]) to last version by David Levy')]
>>> p.getVersionHistory(total=2)
[(615503846, Timestamp(2014, 7, 4, 0, 24, 48), u'Magioladitis', u'Reverted edits by [[Special:Contribs/Magioladitis|Magioladitis]] ([[User talk:Magioladitis|talk]]) to last version by David Levy')]

This change occurred in 2009
http://git.wikimedia.org/commit/pywikibot%2Fcore.git/1946dc13

It can be seen by only running this single test method:

python -m unittest -v tests.page_tests.TestPageObject.testApiMethods
Comment 1 John Mark Vandenberg 2014-10-22 07:07:23 UTC
Bah.  This was caused by a local change.  Sorry.

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


Navigation
Links