summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Ungurianu <alex.ungurianu@protonmail.com>2022-11-02 23:44:33 +0000
committerAlex Ungurianu <alex.ungurianu@protonmail.com>2022-11-16 22:44:04 +0000
commite38b5c5f894432aa21316ba670eba874ba573bbb (patch)
tree48ef17f98ad70b455e1bc69cb3844d3990adc8c0
parent5851e406f578cfb4dc08cf7cdd66d6575cb41ef8 (diff)
downloadkazoo-e38b5c5f894432aa21316ba670eba874ba573bbb.tar.gz
refactor: remove string interpolation in favour of exception chaining
-rw-r--r--kazoo/protocol/connection.py14
-rw-r--r--kazoo/recipe/lock.py4
2 files changed, 9 insertions, 9 deletions
diff --git a/kazoo/protocol/connection.py b/kazoo/protocol/connection.py
index d672497..6ed5cde 100644
--- a/kazoo/protocol/connection.py
+++ b/kazoo/protocol/connection.py
@@ -806,11 +806,11 @@ class ConnectionHandler(object):
try:
response = sasl_cli.process(challenge=challenge)
except puresasl.SASLError as err:
- raise SASLException("library error: %s" % err) from err
- except puresasl.SASLProtocolException as err:
- raise AuthFailedError("protocol error: %s" % err) from err
- except Exception as err:
- raise AuthFailedError("Unknown error: %s" % err) from err
+ raise SASLException("library error") from err
+ except puresasl.SASLProtocolException as exc:
+ raise AuthFailedError("protocol error") from exc
+ except Exception as exc:
+ raise AuthFailedError("Unknown error") from exc
if sasl_cli.complete and not response:
break
@@ -824,9 +824,9 @@ class ConnectionHandler(object):
try:
header, buffer, offset = self._read_header(timeout)
- except ConnectionDropped as ex:
+ except ConnectionDropped as exc:
# Zookeeper simply drops connections with failed authentication
- raise AuthFailedError("Connection dropped in SASL") from ex
+ raise AuthFailedError("Connection dropped in SASL") from exc
if header.xid != xid:
raise RuntimeError(
diff --git a/kazoo/recipe/lock.py b/kazoo/recipe/lock.py
index 5eb66d4..59c6d8f 100644
--- a/kazoo/recipe/lock.py
+++ b/kazoo/recipe/lock.py
@@ -190,12 +190,12 @@ class Lock(object):
)
except RetryFailedError:
pass
- except KazooException as ex:
+ except KazooException:
# if we did ultimately fail, attempt to clean up
if not already_acquired:
self._best_effort_cleanup()
self.cancelled = False
- raise ex
+ raise
if gotten:
self.is_acquired = gotten
if not gotten and not already_acquired: