>>> import pylibmc >>> m = pylibmc.Client(["10.0.0.1"], binary=True) Exception ignored in PyMapping_HasKeyString(); consider using PyMapping_HasKeyStringWithError(), PyMapping_GetOptionalItemString() or PyMapping_GetItemString(): Traceback (most recent call last): File "/usr/lib64/python3.13/site-packages/pylibmc/client.py", line 142, in __init__ super().__init__(servers=translate_server_specs(servers), TypeError: 'NoneType' object is not subscriptable ... Exception ignored in PyMapping_HasKeyString(); consider using PyMapping_HasKeyStringWithError(), PyMapping_GetOptionalItemString() or PyMapping_GetItemString(): Traceback (most recent call last): File "/usr/lib64/python3.13/site-packages/pylibmc/client.py", line 142, in __init__ super().__init__(servers=translate_server_specs(servers), TypeError: 'NoneType' object is not subscriptable python3-pylibmc-1.6.3-7.fc41.x86_64 python3-3.13.0~b3-1.fc41.x86_64
Replacing PyMapping_HasKeyString with PyMapping_HasKeyStringWithError results in: >>> import pylibmc >>> m = pylibmc.Client(["10.0.0.1"], binary=True) Traceback (most recent call last): File "<python-input-1>", line 1, in <module> m = pylibmc.Client(["10.0.0.1"], binary=True) File "/usr/lib64/python3.13/site-packages/pylibmc/client.py", line 142, in __init__ super().__init__(servers=translate_server_specs(servers), ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ binary=binary, ^^^^^^^^^^^^^^ username=username, password=password, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ behaviors=_behaviors_numeric(behaviors)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: 'NoneType' object is not subscriptable ------------- My assumption is this: >>> pylibmc.client._behaviors_numeric(None) is None True When behaviors is None (the default), it passes None to _pylibmc.client behaviors. Without it, it works: >>> _pylibmc.client(servers=pylibmc.client.translate_server_specs(["10.0.0.1"])) <client object at 0x7f0874a59970> But setting it to None fails: >>> _pylibmc.client(servers=pylibmc.client.translate_server_specs(["10.0.0.1"]), behaviors=None) Traceback (most recent call last): File "<python-input-7>", line 1, in <module> _pylibmc.client(servers=pylibmc.client.translate_server_specs(["10.0.0.1"]), behaviors=None) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: 'NoneType' object is not subscriptable Previously, the error resulted in treating the result as if the key was not in the dict. Hence, this should fix this: diff --git a/src/_pylibmcmodule.c b/src/_pylibmcmodule.c index a34d2b5..545b658 100644 --- a/src/_pylibmcmodule.c +++ b/src/_pylibmcmodule.c @@ -2082,7 +2082,7 @@ static PyObject *PylibMC_Client_set_behaviors(PylibMC_Client *self, char *key; for (b = PylibMC_behaviors; b->name != NULL; b++) { - if (!PyMapping_HasKeyString(behaviors, b->name)) { + if (behaviors == Py_None || !PyMapping_HasKeyString(behaviors, b->name)) { continue; } else if ((py_v = PyMapping_GetItemString(behaviors, b->name)) == NULL) { goto error; @@ -2112,7 +2112,7 @@ static PyObject *PylibMC_Client_set_behaviors(PylibMC_Client *self, } for (b = PylibMC_callbacks; b->name != NULL; b++) { - if (!PyMapping_HasKeyString(behaviors, b->name)) { + if (behaviors == Py_None || !PyMapping_HasKeyString(behaviors, b->name)) { continue; } else if ((py_v = PyMapping_GetItemString(behaviors, b->name)) == NULL) { goto error; Indeed: >>> import pylibmc >>> m = pylibmc.Client(["10.0.0.1"], binary=True) >>>
I belive this should fix it: https://github.com/lericson/pylibmc/pull/292
FEDORA-2024-9ec2b42d96 (python-pylibmc-1.6.3-9.fc41) has been submitted as an update to Fedora 41. https://bodhi.fedoraproject.org/updates/FEDORA-2024-9ec2b42d96
FEDORA-2024-9ec2b42d96 (python-pylibmc-1.6.3-9.fc41) has been pushed to the Fedora 41 stable repository. If problem still persists, please make note of it in this bug report.