Skip to content

Commit

Permalink
Don't treat unreadable HTTP errors as Req_Errors
Browse files Browse the repository at this point in the history
So that the code that catches them doesn't assume they
are server responses.
  • Loading branch information
marijnh committed Nov 23, 2016
1 parent 44f006c commit b3c1b3a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tern.py
Expand Up @@ -264,7 +264,10 @@ def f(port, doc):
req = opener.open("http://" + localhost + ":" + str(port) + "/", json.dumps(doc).encode("utf-8"), 1)
return json.loads(req.read().decode("utf-8"))
except urllib.error.URLError as error:
raise Req_Error((hasattr(error, "read") and error.read().decode("utf-8")) or str(error.reason))
if hasattr(error, "read"):
raise Req_Error(error.read().decode("utf-8"))
else:
raise error
return f

if python3:
Expand Down

0 comments on commit b3c1b3a

Please sign in to comment.