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 Feb 25, 2024
1 parent a0b820d commit 316667e
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 @@ -5010,14 +5010,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 316667e

Please sign in to comment.