From 2821f0f667b550b7eab4a118c15ac66f39609366 Mon Sep 17 00:00:00 2001 From: "kuldeep.k@cisinlabs.com" Date: Tue, 7 Sep 2021 22:22:07 +0530 Subject: [PATCH] Shifted try except block placement --- src/namecoin.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/namecoin.py b/src/namecoin.py index 381a04b0..2a94f1ce 100644 --- a/src/namecoin.py +++ b/src/namecoin.py @@ -245,18 +245,19 @@ class namecoinConnection(object): "Authorization", "Basic %s" % base64.b64encode(authstr)) self.con.endheaders() self.con.send(data) - try: - resp = self.con.getresponse() - result = resp.read() - if resp.status != 200: - raise Exception( - "Namecoin returned status" - " %i: %s" % (resp.status, resp.reason)) - except: # noqa:E722 - logger.info("HTTP receive error") except: # noqa:E722 logger.info("HTTP connection error") + try: + resp = self.con.getresponse() + result = resp.read() + if resp.status != 200: + raise Exception( + "Namecoin returned status" + " %i: %s" % (resp.status, resp.reason)) + except: # noqa:E722 + logger.info("HTTP receive error") + return result def queryServer(self, data):