Skip to content

Commit

Permalink
Merge "[bugfix] Upcast to FilePage in PageGenerator.result()"
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Nov 22, 2024
2 parents 01db35c + 818c56e commit c1d9963
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pywikibot/data/api/_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,9 +727,12 @@ def result(self, pagedata: dict[str, Any]) -> pywikibot.Page:
of object.
.. versionchanged:: 9.5
no longer raise :exc:`exceptions.UnsupportedPageError` but
No longer raise :exc:`exceptions.UnsupportedPageError` but
return a generic :class:`pywikibot.Page` obect. The exception
is raised when getting the content for example.
.. versionchanged:: 9.6
Upcast to :class:`page.FilePage` if *pagedata* has
``imageinfo`` contents even if the file extension is invalid.
"""
p = pywikibot.Page(self.site, pagedata['title'], pagedata['ns'])
ns = pagedata['ns']
Expand All @@ -738,7 +741,8 @@ def result(self, pagedata: dict[str, Any]) -> pywikibot.Page:
p = pywikibot.User(p)
elif ns == Namespace.FILE:
with suppress(ValueError):
p = pywikibot.FilePage(p)
p = pywikibot.FilePage(
p, ignore_extension='imageinfo' in pagedata)
elif ns == Namespace.CATEGORY:
p = pywikibot.Category(p)

Expand Down

0 comments on commit c1d9963

Please sign in to comment.