Skip to content

Commit e38b5c5

Browse files
committed
refactor: remove string interpolation in favour of exception chaining
1 parent 5851e40 commit e38b5c5

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

kazoo/protocol/connection.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -806,11 +806,11 @@ def _authenticate_with_sasl(self, host, timeout):
806806
try:
807807
response = sasl_cli.process(challenge=challenge)
808808
except puresasl.SASLError as err:
809-
raise SASLException("library error: %s" % err) from err
810-
except puresasl.SASLProtocolException as err:
811-
raise AuthFailedError("protocol error: %s" % err) from err
812-
except Exception as err:
813-
raise AuthFailedError("Unknown error: %s" % err) from err
809+
raise SASLException("library error") from err
810+
except puresasl.SASLProtocolException as exc:
811+
raise AuthFailedError("protocol error") from exc
812+
except Exception as exc:
813+
raise AuthFailedError("Unknown error") from exc
814814

815815
if sasl_cli.complete and not response:
816816
break
@@ -824,9 +824,9 @@ def _authenticate_with_sasl(self, host, timeout):
824824

825825
try:
826826
header, buffer, offset = self._read_header(timeout)
827-
except ConnectionDropped as ex:
827+
except ConnectionDropped as exc:
828828
# Zookeeper simply drops connections with failed authentication
829-
raise AuthFailedError("Connection dropped in SASL") from ex
829+
raise AuthFailedError("Connection dropped in SASL") from exc
830830

831831
if header.xid != xid:
832832
raise RuntimeError(

kazoo/recipe/lock.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,12 @@ def acquire(self, blocking=True, timeout=None, ephemeral=True):
190190
)
191191
except RetryFailedError:
192192
pass
193-
except KazooException as ex:
193+
except KazooException:
194194
# if we did ultimately fail, attempt to clean up
195195
if not already_acquired:
196196
self._best_effort_cleanup()
197197
self.cancelled = False
198-
raise ex
198+
raise
199199
if gotten:
200200
self.is_acquired = gotten
201201
if not gotten and not already_acquired:

0 commit comments

Comments
 (0)