Skip to content

Commit 6b524e6

Browse files
Fix protocol validation: replace finally with else and store parsed int (#3965)
Co-authored-by: petyaslavova <petya.slavova@redis.com>
1 parent 5f4ded8 commit 6b524e6

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

redis/asyncio/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,10 @@ def __init__(
245245
p = DEFAULT_RESP_VERSION
246246
except ValueError:
247247
raise ConnectionError("protocol must be an integer")
248-
finally:
248+
else:
249249
if p < 2 or p > 3:
250250
raise ConnectionError("protocol must be either 2 or 3")
251-
self.protocol = protocol
251+
self.protocol = p
252252

253253
def __del__(self, _warnings: Any = warnings):
254254
# For some reason, the individual streams don't get properly garbage

redis/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ def __init__(
881881
p = DEFAULT_RESP_VERSION
882882
except ValueError:
883883
raise ConnectionError("protocol must be an integer")
884-
finally:
884+
else:
885885
if p < 2 or p > 3:
886886
raise ConnectionError("protocol must be either 2 or 3")
887887
# p = DEFAULT_RESP_VERSION

0 commit comments

Comments
 (0)