Skip to content

Commit ce9eb83

Browse files
authored
Fix parsing of FT.PROFILE result (#3063)
* Fix parsing of ft.profile result * test
1 parent e13356d commit ce9eb83

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

redis/commands/helpers.py

+5
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ def parse_list_to_dict(response):
6464
for i in range(0, len(response), 2):
6565
if isinstance(response[i], list):
6666
res["Child iterators"].append(parse_list_to_dict(response[i]))
67+
try:
68+
if isinstance(response[i + 1], list):
69+
res["Child iterators"].append(parse_list_to_dict(response[i + 1]))
70+
except IndexError:
71+
pass
6772
elif isinstance(response[i + 1], list):
6873
res["Child iterators"] = [parse_list_to_dict(response[i + 1])]
6974
else:

tests/test_helpers.py

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def test_parse_to_dict():
4141
"Child iterators",
4242
["Type", "bar", "Time", "0.0729", "Counter", 3],
4343
["Type", "barbar", "Time", "0.058", "Counter", 3],
44+
["Type", "barbarbar", "Time", "0.0234", "Counter", 3],
4445
],
4546
],
4647
]
@@ -49,6 +50,7 @@ def test_parse_to_dict():
4950
"Child iterators": [
5051
{"Counter": 3.0, "Time": 0.0729, "Type": "bar"},
5152
{"Counter": 3.0, "Time": 0.058, "Type": "barbar"},
53+
{"Counter": 3.0, "Time": 0.0234, "Type": "barbarbar"},
5254
],
5355
"Counter": 3.0,
5456
"Time": 0.2089,

0 commit comments

Comments
 (0)