Skip to content

Commit

Permalink
Fix parsing resp3 dicts (#2982)
Browse files Browse the repository at this point in the history
  • Loading branch information
kristjanvalur committed Nov 13, 2023
1 parent c2d5596 commit 0113034
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions redis/_parsers/resp3.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ def _read_response(self, disable_decoding=False, push_request=False):
pass
# map response
elif byte == b"%":
# we use this approach and not dict comprehension here
# because this dict comprehension fails in python 3.7
# We cannot use a dict-comprehension to parse stream.
# Evaluation order of key:val expression in dict comprehension only
# became defined to be left-right in version 3.8
resp_dict = {}
for _ in range(int(response)):
key = self._read_response(disable_decoding=disable_decoding)
Expand Down Expand Up @@ -225,12 +226,16 @@ async def _read_response(
pass
# map response
elif byte == b"%":
response = {
(await self._read_response(disable_decoding=disable_decoding)): (
await self._read_response(disable_decoding=disable_decoding)
# We cannot use a dict-comprehension to parse stream.
# Evaluation order of key:val expression in dict comprehension only
# became defined to be left-right in version 3.8
resp_dict = {}
for _ in range(int(response)):
key = await self._read_response(disable_decoding=disable_decoding)
resp_dict[key] = await self._read_response(
disable_decoding=disable_decoding, push_request=push_request
)
for _ in range(int(response))
}
response = resp_dict
# push response
elif byte == b">":
response = [
Expand Down

0 comments on commit 0113034

Please sign in to comment.