jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[fix] no longer raise UnsupportedPageError within PageGenerator.result()

Bug: T377651
Change-Id: I6f55ca09c55f3c3fd0368a59be2bf0d5164aa9fb
---
M pywikibot/data/api/_generators.py
M tests/page_tests.py
2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/pywikibot/data/api/_generators.py b/pywikibot/data/api/_generators.py
index 69ca560..6f1206d 100644
--- a/pywikibot/data/api/_generators.py
+++ b/pywikibot/data/api/_generators.py
@@ -727,6 +727,10 @@
This can be overridden in subclasses to return a different type
of object.

+ .. versionchanged:: 9.4
+ no longer raise :exc:`exceptions.UnsupportedPageError` but
+ return a generic :class:`pywikibot.Page` obect. The exception
+ is raised when getting the content for example.
"""
p = pywikibot.Page(self.site, pagedata['title'], pagedata['ns'])
ns = pagedata['ns']
@@ -738,7 +742,10 @@
p = pywikibot.FilePage(p)
elif ns == Namespace.CATEGORY:
p = pywikibot.Category(p)
- update_page(p, pagedata, self.props)
+
+ with suppress(UnsupportedPageError):
+ update_page(p, pagedata, self.props)
+
return p


diff --git a/tests/page_tests.py b/tests/page_tests.py
index 0651e34..716bb8c 100755
--- a/tests/page_tests.py
+++ b/tests/page_tests.py
@@ -853,6 +853,12 @@
self.assertFalse(page.botMayEdit())
del page

+ def test_real_page(self):
+ """Test botMayEdit for real example due to T377651."""
+ site = pywikibot.Site('wikipedia:en')
+ page = pywikibot.Page(site, 'Talk:Alan Turing')
+ self.assertTrue(page.botMayEdit())
+

class TestPageHistory(DefaultSiteTestCase):


To view, visit change 1081475. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I6f55ca09c55f3c3fd0368a59be2bf0d5164aa9fb
Gerrit-Change-Number: 1081475
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot