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 <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>