https://bugzilla.wikimedia.org/show_bug.cgi?id=72344
Bug ID: 72344 Summary: Page.previousRevision exception Product: Pywikibot Version: core (2.0) Hardware: All OS: All Status: NEW Severity: critical Priority: Unprioritized Component: General Assignee: Pywikipedia-bugs@lists.wikimedia.org Reporter: jayvdb@gmail.com Web browser: --- Mobile Platform: ---
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
https://bugzilla.wikimedia.org/show_bug.cgi?id=72344
John Mark Vandenberg jayvdb@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugzilla.wikimedia. | |org/show_bug.cgi?id=64188 Blocks| |70936
https://bugzilla.wikimedia.org/show_bug.cgi?id=72344
John Mark Vandenberg jayvdb@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Blocks|70936 | Resolution|--- |WORKSFORME
--- Comment #1 from John Mark Vandenberg jayvdb@gmail.com --- Bah. This was caused by a local change. Sorry.
pywikipedia-bugs@lists.wikimedia.org