jenkins-bot has submitted this change and it was merged.

Change subject: Provide more info in case of invalid page
......................................................................


Provide more info in case of invalid page

Display the api error message, if possible, which is more informative
than current AssertionError.

Bug: T132158
Change-Id: If95a6930eac8c021a8799a7988e3d079a304e838
---
M pywikibot/data/api.py
1 file changed, 7 insertions(+), 1 deletion(-)

Approvals:
  Xqt: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index c3f1ddf..40999c6 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -34,7 +34,9 @@
 
 from pywikibot.comms import http
 from pywikibot.exceptions import (
-    Server504Error, Server414Error, FatalServerError, NoUsername, Error
+    Server504Error, Server414Error, FatalServerError, NoUsername,
+    Error,
+    InvalidTitle
 )
 from pywikibot.tools import (
     MediaWikiVersion, deprecated, itergroup, ip, PY2, getargspec,
@@ -3118,6 +3120,10 @@
     elif "missing" in pagedict:
         page._pageid = 0    # Non-existent page
     else:
+        # Something is wrong.
+        if page.site.sametitle(page.title(), pagedict['title']):
+            if 'invalid' in pagedict:
+                raise InvalidTitle('%s: %s' % (page, 
pagedict['invalidreason']))
         raise AssertionError(
             "Page %s has neither 'pageid' nor 'missing' attribute" % 
pagedict['title'])
     page._contentmodel = pagedict.get('contentmodel')  # can be None

-- 
To view, visit https://gerrit.wikimedia.org/r/285092
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If95a6930eac8c021a8799a7988e3d079a304e838
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Mpaa <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: Zhuyifei1999 <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to