hiredis-py
hiredis-py copied to clipboard
Return type differs between RESP2/3 for set operations, with hiredis
Summary
With hiredis, set operations (such as SMEMBERS) returns different types between RESP2 and RESP3.
I confirmed the difference was not observed without hiredis.
Versions
Redis(server): 7.4.0 Python: 3.12.4 redis(Python Library): 5.0.8 hiredis(Python Library): 3.0.0
Example
Code:
from redis import Redis
client = Redis(protocol=2)
print("RESP2")
print(type(client.smembers("test-set")))
print(type(client.sunion("test-set")))
print(type(client.sdiff("test-set")))
print(type(client.sinter("test-set")))
client = Redis(protocol=3)
print("RESP3")
print(type(client.smembers("test-set")))
print(type(client.sunion("test-set")))
print(type(client.sdiff("test-set")))
print(type(client.sinter("test-set")))
Output:
RESP2
<class 'set'>
<class 'set'>
<class 'set'>
<class 'set'>
RESP3
<class 'list'>
<class 'list'>
<class 'list'>
<class 'list'>
Is this relevant? #189
@aosh-ab7e It's a breaking change in 3.0 release to revert it back you should use hiredis-py < 3.0
This is fixed in redis-py 5.1.1 (https://github.com/redis/redis-py/pull/3399).