Bugs item #3595741, was opened at 2012-12-13 17:38
Message generated for change (Tracker Item Submitted) made by stefan2wiki
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=359574…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Stefan2 (stefan2wiki)
Assigned to: Nobody/Anonymous (nobody)
Summary: getFileVersionHistory doesn't work if information is hidden
Initial Comment:
Take a file where some information is hidden, for example this one:
https://commons.wikimedia.org/wiki/File:Catania_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 "wikipedia.py", 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 (wikipedia.py), 2012/11/13, 20:56:05)
Python 2.7.3 (default, Aug 1 2012, 05:16:07)
[GCC 4.6.3]
config-settings:
use_api = True
use_api_login = True
unicode test: ok
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=359574…