Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop accessing None as a dictionary #292

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hroncok
Copy link

@hroncok hroncok commented Jul 3, 2024

PyMapping_HasKeyString does not work on None
Accidentally, it used to return false result on silent errors.

Since Python 3.13, this is what happens instead:

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

When this is run via pytest, it leads to:

pytest.PytestUnraisableExceptionWarning: Exception ignored in PyMapping_HasKeyString(); consider using PyMapping_HasKeyStringWithError(), PyMapping_GetOptionalItemString() or PyMapping_GetItemString(): None

Fixes pallets-eco/cachelib#400

PyMapping_HasKeyString does not work on None
Accidentally, it used to return false result on silent errors.

Since Python 3.13, this is what happens instead:

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

When this is run via pytest, it leads to:

    pytest.PytestUnraisableExceptionWarning: Exception ignored in PyMapping_HasKeyString(); consider using PyMapping_HasKeyStringWithError(), PyMapping_GetOptionalItemString() or PyMapping_GetItemString(): None

Fixes pallets-eco/cachelib#400
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant