Page MenuHomePhabricator

getFileVersionHistory doesn't work if information is hidden
Closed, DeclinedPublic


Originally from:
Reported by: stefan2wiki
Created on: 2012-12-14 01:38:42
Subject: getFileVersionHistory doesn't work if information is hidden
Original description:
Take a file where some information is hidden, for example this one:\_Piazza\_Quattro\_Canti.jpg
In this case, the edit summary for the first revision is missing.

Try this code:

import wikipedia
site = wikipedia.getSite\(u'commons', u'commons'\)
page = wikipedia.ImagePage\(site, u'File:Catania Piazza Quattro Canti.jpg'\)
history = page.getFileVersionHistory\(\)

I get an error message:

Traceback \(most recent call last\):
File "<stdin>", line 1, in <module>
File "", line 4194, in getFileVersionHistory
result.append\(\(i\['timestamp'\], i\['user'\], u"%s×%s" % \(i\['width'\], i\['height'\]\), i\['size'\], i\['comment'\]\)\)
KeyError: 'comment'

There is no i\['comment'\] because the comment is hidden \(deleted\).

Result: The script crashes when running getFileVersionHistory. It would be better if getFileVersionHistory at least returns what's available, instead of returning nothing at all. For example, if you use i.get\('comment'\) instead of i\['comment'\], then getFileVersionHistory returns None if there is no comment. That seems much better than crashing.

Some version information:
Pywikipedia \(r10715 \(\), 2012/11/13, 20:56:05\)
Python 2.7.3 \(default, Aug 1 2012, 05:16:07\)
\[GCC 4.6.3\]
use\_api = True
use\_api\_login = True
unicode test: ok

Version: compat-(1.0)
Severity: major
See Also:



Event Timeline

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

Need to determine if this problem exists on core.

(In reply to John Mark Vandenberg from comment #1)

Need to determine if this problem exists on core.

In core:
history = page.getFileVersionHistory() returns a list without crashing.

When trying to fetch the hidden comment, the result is:


Traceback (most recent call last):

File "<stdin>", line 1, in <module>

KeyError: 'comment

To note that history returns a "commenthidden" key in this case:




"timestamp": "2007-02-14T13:01:57Z",
"user": "Messina",
"commenthidden": "",
"url": "",
"descriptionurl": ""


Aklapper triaged this task as Lowest priority.Jun 5 2015, 1:41 PM
Aklapper subscribed.

Pywikibot has two versions: Compat and Core. This task was filed about the older version, called Pywikibot-compat, which is not under active development anymore. Hence I'm lowering the priority of this task to reflect the reality. Unfortunately, the Pywikibot team does not have the manpower to retest every single bug report / feature request against the (maintained) Pywikibot code base. Furthermore, the code base of Pywikibot-Compat has changed a lot compared to the code base of Pywikibot-Core so there is a chance that the problem described in this task might not exist anymore. Please help: Unfortunately manpower is limited and does not allow testing every single reported task again. If you have time and interest in Pywikibot, please upgrade to Pywikibot-Core and add a comment to this task if the problem in this task still happens in Pywikibot-Core (or directly edit the task by removing the Pywikibot-compat project and adding the Pywikibot project to this task). To learn more about Pywikibot and to get involved in its development, please check out Thank you for your understanding.

Xqt raised the priority of this task from Lowest to Low.EditedMar 14 2016, 4:50 PM
Xqt edited projects, added Pywikibot; removed Pywikibot-compat.
Xqt subscribed.
This comment has been deleted.

works for core.