From 1bd91aa2d93ac05a33034a235549ba486fb85ce5 Mon Sep 17 00:00:00 2001 From: Taylor Dawson Date: Fri, 23 Jun 2017 16:27:52 -0700 Subject: [PATCH] Fix Issue #5 Added a check for a http response that has a status code of 200 but is completely empty. This will prevent the function json.loads() from being excuted with an empty string. Issue source: https://github.com/corpetty/py-etherscan-api/issues/5 --- etherscan/client.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/etherscan/client.py b/etherscan/client.py index 613f56a..6bf8872 100644 --- a/etherscan/client.py +++ b/etherscan/client.py @@ -47,7 +47,12 @@ def connect(self): except requests.exceptions.ConnectionError: return "Connection refused" if req.status_code == 200: - return json.loads(req.text) + # Check for empty response + if req.text: + return json.loads(req.text) + else: + print("Invalid Request") + exit() else: print("problem with connection, status code: ", req.status_code) exit()