Skip to content

Commit

Permalink
Fix: hset unexpectedly mutates the list passed to items (#3103)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvora-h committed Jan 11, 2024
1 parent 4a66c1e commit 273f032
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions redis/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5017,14 +5017,16 @@ def hset(
"""
if key is None and not mapping and not items:
raise DataError("'hset' with no key value pairs")
items = items or []
pieces = []
if items:
pieces.extend(items)
if key is not None:
items.extend((key, value))
pieces.extend((key, value))
if mapping:
for pair in mapping.items():
items.extend(pair)
pieces.extend(pair)

return self.execute_command("HSET", name, *items)
return self.execute_command("HSET", name, *pieces)

def hsetnx(self, name: str, key: str, value: str) -> Union[Awaitable[bool], bool]:
"""
Expand Down

0 comments on commit 273f032

Please sign in to comment.