Skip to content

Commit 316667e

Browse files
committed
Fix: hset unexpectedly mutates the list passed to items (#3103)
1 parent a0b820d commit 316667e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

redis/commands/core.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -5010,14 +5010,16 @@ def hset(
50105010
"""
50115011
if key is None and not mapping and not items:
50125012
raise DataError("'hset' with no key value pairs")
5013-
items = items or []
5013+
pieces = []
5014+
if items:
5015+
pieces.extend(items)
50145016
if key is not None:
5015-
items.extend((key, value))
5017+
pieces.extend((key, value))
50165018
if mapping:
50175019
for pair in mapping.items():
5018-
items.extend(pair)
5020+
pieces.extend(pair)
50195021

5020-
return self.execute_command("HSET", name, *items)
5022+
return self.execute_command("HSET", name, *pieces)
50215023

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

0 commit comments

Comments
 (0)