jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/333215 )
Change subject: FilePage.get_file_history(): Check for len(self._file_revisions) ......................................................................
FilePage.get_file_history(): Check for len(self._file_revisions)
Previously it was hasattr(self, '_file_revisions'), which will always return True due to attribute being set on instance initialization.
Unlike other cacheing logic such as templates or categories that use hasattr check, we keep this logic of len check due to the fact that a file page must have a file revision, and many methods expects the self._file_revisions dict to be non-empty.
Bug: T155740 Change-Id: I4f35971a3f45f6ffed20135f45c5050f862a0d92 --- M pywikibot/page.py 1 file changed, 1 insertion(+), 1 deletion(-)
Approvals: Dalba: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py index e7aa8e3..f015e45 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -2346,7 +2346,7 @@ value: instance of FileInfo() @rtype: dict """ - if not hasattr(self, '_file_revisions'): + if not len(self._file_revisions): self.site.loadimageinfo(self, history=True) return self._file_revisions