Skip to content

Commit b3e3fae

Browse files
maxxiefjvc00kiemon5ter
authored andcommitted
Ensure RedisWrapper.items returns a list of strings
The return type of the _db.keys() is List[_StrType], where _StrType is a str or bytes. As we want the items() method to return strings (given the provided __getitem__ method) for keys we need an additional check.
1 parent c7abebc commit b3e3fae

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/pyop/storage.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ def __contains__(self, key):
155155
def items(self):
156156
for key in self._db.keys(self._collection + "*"):
157157
visible_key = key[len(self._collection) + 1 :]
158+
159+
if isinstance(visible_key, bytes):
160+
visible_key = visible_key.decode()
161+
158162
try:
159163
yield (visible_key, self[visible_key])
160164
except KeyError:

0 commit comments

Comments
 (0)