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 <>
Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #3417
Status: Errored
Duration: 1 hour, 1 minute, and 33 seconds
Commit: 20faf0c (master)
Author: xqt
Message: [bugfix] Enable test_detect_site for wikichristian.org
- SiteDetectionTestCase.test_detect_site() failed for wikichristian.org.
I found several newlines on top of the json file and a Byte Order Mark (BOM).
Removing them solves the problem.
- Also add a __repr__ for MWSite so show this repr string instead of the
generic <pywikibot.site_detect.MWSite object at 0x032D06F0>. Now we get
the class Name with the new url where the json is fetched from
Bug: T128992
Change-Id: Ib8b4c0d5dbf645d4984d26f5ac35f8f98e1ca418
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/75134ba52d9a...20faf0cf…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/125397549
--
You can configure recipients for build notifications in your .travis.yml file. See https://docs.travis-ci.com/user/notifications