site_detect_tests fails for StandardVersionSiteTestCase.test_wikichristian with
AttributeError: 'MWSite' object has no attribute 'private_wiki'
in constructor of MWSite. (travis)
Description
Details
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
Resolved | Magul | T151145 Make Travis (and Appveyor) pass again | |||
Resolved | Dalba | T160355 site_detect_tests fails with AttributeError in constructor of MWSite |
Event Timeline
Digging deeper shows the warning:
tests/site_detect_tests.py::StandardVersionSiteTestCase::test_wikichristian WARNING: Http response status 500
FAILED
which means request.status is not in (200, 207) but ServerError('Internal Server Error') for isn't raised by MWSite constructor for request.status==500
private_wiki is not set because _parse_post_117 method is getting a server error status from the server and ignores it. We should check for server errors inside _parse_post_117, just the way we do in MWSite.__init__.
To be more specific, inside _parse_post_117, when the response.status is 500, response.content.strip().lstrip('\uFEFF') will be an empty string, therefore json.loads(content) will fail with JSONDecodeError. This error is ignored by the try-except statement that is wrapping _parse_post_117.
Change 349156 had a related patch set uploaded (by Dalba):
[pywikibot/core@master] site_detect.py: Check the response in _parse_post_117 for server errors
Change 349156 merged by jenkins-bot:
[pywikibot/core@master] site_detect.py: Check the response in _parse_post_117 for server errors
This happened again in https://travis-ci.org/wikimedia/pywikibot-core/jobs/237649587#L4782
It seems that the fetch inside the _parse_post_117 method is raising some kind of exception...
I'll send a patch for review.
Change 356432 had a related patch set uploaded (by Dalba; owner: Dalba):
[pywikibot/core@master] MWSite.init: Re-raise the RequestException of _parse_post_117
Change 356432 merged by jenkins-bot:
[pywikibot/core@master] MWSite.init: Re-raise the RequestException of _parse_post_117