Page MenuHomePhabricator

'Maximum retries' api.py exception is not Python 3 compatible
Closed, InvalidPublic

Description

In this py3 build, there are some network issues, and py3 exception handling shows three exceptions, including json decoding exceptions. The result is confusing to someone unfamiliar with py3 or not intimately aware of how the api.py request error handling is organised.

https://travis-ci.org/wikimedia/pywikibot-core/jobs/39178815

======================================================================
ERROR: testLinkMethods (tests.site_tests.TestSiteObject)
Test site methods for getting links to and from a page.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/python/3.3.5/lib/python3.3/json/decoder.py", line 367, in raw_decode
    obj, end = self.scan_once(s, idx)
StopIteration
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/travis/build/wikimedia/pywikibot-core/pywikibot/data/api.py", line 606, in submit
    result = json.loads(rawdata)
  File "/opt/python/3.3.5/lib/python3.3/json/__init__.py", line 316, in loads
    return _default_decoder.decode(s)
  File "/opt/python/3.3.5/lib/python3.3/json/decoder.py", line 351, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/python/3.3.5/lib/python3.3/json/decoder.py", line 369, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/travis/build/wikimedia/pywikibot-core/tests/site_tests.py", line 331, in testLinkMethods
    filterRedirects=False))
  File "/home/travis/build/wikimedia/pywikibot-core/pywikibot/site.py", line 2582, in pagebacklinks
    content=content
  File "/home/travis/build/wikimedia/pywikibot-core/pywikibot/site.py", line 2568, in pagebacklinks
    for redir in redirgen:
  File "/home/travis/build/wikimedia/pywikibot-core/pywikibot/data/api.py", line 1095, in __iter__
    self.data = self.request.submit()
  File "/home/travis/build/wikimedia/pywikibot-core/pywikibot/data/api.py", line 828, in submit
    self._data = super(CachedRequest, self).submit()
  File "/home/travis/build/wikimedia/pywikibot-core/pywikibot/data/api.py", line 624, in submit
    self.wait()
  File "/home/travis/build/wikimedia/pywikibot-core/pywikibot/data/api.py", line 711, in wait
    raise TimeoutError("Maximum retries attempted without success.")
pywikibot.data.api.TimeoutError: Maximum retries attempted without success.

Version: core-(2.0)
Severity: normal

Details

Reference
bz72603

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 3:56 AM
bzimport added a project: Pywikibot-network.
bzimport set Reference to bz72603.
bzimport added a subscriber: Unknown Object (????).
jayvdb created this task.Oct 28 2014, 4:23 AM
XZise triaged this task as Lowest priority.Jan 18 2015, 8:54 PM
XZise added a subscriber: XZise.

I'm not sure this is a valid bug. Yes three tracebacks look more intimidating, but if we show that any unfamiliar will be intimidated no matter if only the last or all three are shown.

If it's changed it shouldn't be Python 3 specific but work on both versions and then something like that it only prints the error message to the console and the traceback to a log. Problem with that solution however is when the log wasn't activated because than the traceback is lost.

XZise updated the task description. (Show Details)Jan 18 2015, 8:55 PM
XZise set Security to None.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 18 2015, 6:01 PM

I don't think this is a bug either. In fact, IMO this helps a lot in debugging when you want to understand the exact code paths

Xqt closed this task as Invalid.Aug 3 2018, 7:28 PM
Xqt added a subscriber: Xqt.

See comments above