Page MenuHomePhabricator

FilePage.get_file_history() returns a dict with timestamp as key but all scripts expect a sequence
Open, HighPublicBUG REPORT


List of steps to reproduce:

What happens?:
get the first or last item of the sequence (using pop()) fails with KeyError or TypeError

What should have happened instead?:
Either return a sequence (or generator) with get_file_history or describe a way how to find the first or last item in the dict e.g.

hist = image.get_file_history()
key = sorted(hist.keys())
item = hist.pop(key)

Software version:
Pywikibot 3.0.20170403 or earlier. Strange that is was not detected the last 7 years

Event Timeline

Xqt added a subscriber: Meno25.

The return type is specified clearly.
Scripts that use this function know what to expect and should act accordingly.

latest_file_info(self) and oldest_file_info(self) are available for that purpose.

I find problematic that someone pop() an item, as the cached self._file_revisions dict will be corrupted.
It should be clarified in the docstring or a copy should be returned.