redis / hiredis-py

Python wrapper for hiredis
MIT License
494 stars 102 forks source link

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

Open aosh-ab7e opened 1 month ago

aosh-ab7e commented 1 month ago

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 commented 1 month ago

Is this relevant?

189