jenkins-bot has submitted this change and it was merged.
Change subject: [bugfix] Enable test_detect_site for
wikichristian.org
......................................................................
[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
---
M pywikibot/site_detect.py
1 file changed, 7 insertions(+), 1 deletion(-)
Approvals:
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site_detect.py b/pywikibot/site_detect.py
index 61ac438..a6a3003 100644
--- a/pywikibot/site_detect.py
+++ b/pywikibot/site_detect.py
@@ -104,6 +104,10 @@
self.version < MediaWikiVersion('1.14')):
raise RuntimeError('Unsupported version: {0}'.format(self.version))
+ def __repr__(self):
+ return '{0}("{1}")'.format(
+ self.__class__.__name__, self.fromurl)
+
@property
def langs(self):
"""Build interwikimap."""
@@ -157,7 +161,9 @@
def _parse_post_117(self):
"""Parse 1.17+ siteinfo data."""
response = fetch(self.api +
'?action=query&meta=siteinfo&format=json')
- info = json.loads(response.content)
+ # remove preleading newlines and Byte Order Mark (BOM), see T128992
+ content = response.content.strip().lstrip('\uFEFF')
+ info = json.loads(content)
self.private_wiki = ('error' in info and
info['error']['code'] ==
'readapidenied')
if self.private_wiki:
--
To view, visit
https://gerrit.wikimedia.org/r/285071
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib8b4c0d5dbf645d4984d26f5ac35f8f98e1ca418
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>