hiredis-py icon indicating copy to clipboard operation
hiredis-py copied to clipboard

Return type differs between RESP2/3 for set operations, with hiredis

Open aosh-ab7e opened this issue 1 year ago • 1 comments

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'>

aosh-ab7e avatar Aug 07 '24 08:08 aosh-ab7e

Is this relevant? #189

aosh-ab7e avatar Aug 07 '24 08:08 aosh-ab7e

@aosh-ab7e It's a breaking change in 3.0 release to revert it back you should use hiredis-py < 3.0

uglide avatar Apr 23 '25 11:04 uglide

This is fixed in redis-py 5.1.1 (https://github.com/redis/redis-py/pull/3399).

aosh-ab7e avatar Apr 25 '25 09:04 aosh-ab7e