Closed
Description
when i read code in getex() method, i found that use set to check mutually exclusive between options may not be right:
valkey-py/valkey/commands/core.py
Lines 1862 to 1867 in c490780
if ex and px has the same value, this condition will be False:
>>> from valkey import Valkey
>>> v = Valkey(host='127.0.0.1', port=6888, password='xxxx')
>>> v.getex("hello", 10, 10)
Traceback (most recent call last):
File "<python-input-3>", line 1, in <module>
v.getex("hello", 10, 10)
~~~~~~~^^^^^^^^^^^^^^^^^
File "/root/.pyenv/versions/env-3.13/lib/python3.13/site-packages/valkey/commands/core.py", line 1895, in getex
return self.execute_command("GETEX", name, *pieces)
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.pyenv/versions/env-3.13/lib/python3.13/site-packages/valkey/client.py", line 570, in execute_command
response = conn.retry.call_with_retry(
lambda: self._send_command_parse_response(
...<2 lines>...
lambda error: self._disconnect_raise(conn, error),
)
File "/root/.pyenv/versions/env-3.13/lib/python3.13/site-packages/valkey/retry.py", line 62, in call_with_retry
return do()
File "/root/.pyenv/versions/env-3.13/lib/python3.13/site-packages/valkey/client.py", line 571, in <lambda>
lambda: self._send_command_parse_response(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
conn, command_name, *args, **options
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
),
^
File "/root/.pyenv/versions/env-3.13/lib/python3.13/site-packages/valkey/client.py", line 543, in _send_command_parse_response
return self.parse_response(conn, command_name, **options)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.pyenv/versions/env-3.13/lib/python3.13/site-packages/valkey/client.py", line 590, in parse_response
response = connection.read_response()
File "/root/.pyenv/versions/env-3.13/lib/python3.13/site-packages/valkey/connection.py", line 570, in read_response
raise response
valkey.exceptions.ResponseError: syntax error
>>>
so i think use list instead of set will be more accurate, although it's not simple enough:
opvset = [1 for op in [ex, px, exat, pxat] if op is not None]
if sum(opvset) > 1 or (sum(opvset) and persist):
raise DataError(
"``ex``, ``px``, ``exat``, ``pxat``, "
"and ``persist`` are mutually exclusive."
)