Skip to content

Tests fail with Python 3.11: AttributeError: 'NoneType' object has no attribute 'pop' #325

@s3v-

Description

@s3v-

Some tests start failing with Python 3.11.
See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1027503

> ======================================================================
> ERROR: Test the get_version function.
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_apptools/build/apptools/persistence/tests/test_version_registry.py", line 69, in test_get_version
>     state = state_pickler.get_state(c)
>             ^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_apptools/build/apptools/persistence/state_pickler.py", line 996, in get_state
>     s = dumps(obj)
>         ^^^^^^^^^^
>   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_apptools/build/apptools/persistence/state_pickler.py", line 968, in dumps
>     return StatePickler().dumps(value)
>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_apptools/build/apptools/persistence/state_pickler.py", line 308, in dumps
>     return pickle.dumps(self._do(value))
>                         ^^^^^^^^^^^^^^^
>   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_apptools/build/apptools/persistence/state_pickler.py", line 358, in _do
>     return self._do_instance(obj)
>            ^^^^^^^^^^^^^^^^^^^^^^
>   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_apptools/build/apptools/persistence/state_pickler.py", line 403, in _do_instance
>     state.pop("__traits_version__", None)
>     ^^^^^^^^^
> AttributeError: 'NoneType' object has no attribute 'pop'
> 
> ======================================================================
> ERROR: Test if update method calls the handlers in order.
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_apptools/build/apptools/persistence/tests/test_version_registry.py", line 111, in test_update
>     state = state_pickler.get_state(c)
>             ^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_apptools/build/apptools/persistence/state_pickler.py", line 996, in get_state
>     s = dumps(obj)
>         ^^^^^^^^^^
>   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_apptools/build/apptools/persistence/state_pickler.py", line 968, in dumps
>     return StatePickler().dumps(value)
>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_apptools/build/apptools/persistence/state_pickler.py", line 308, in dumps
>     return pickle.dumps(self._do(value))
>                         ^^^^^^^^^^^^^^^
>   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_apptools/build/apptools/persistence/state_pickler.py", line 358, in _do
>     return self._do_instance(obj)
>            ^^^^^^^^^^^^^^^^^^^^^^
>   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_apptools/build/apptools/persistence/state_pickler.py", line 403, in _do_instance
>     state.pop("__traits_version__", None)
>     ^^^^^^^^^
> AttributeError: 'NoneType' object has no attribute 'pop'
> 
> ----------------------------------------------------------------------
> Ran 355 tests in 1.754s
> 
> FAILED (errors=2)

Please note that every pyckable object has _getstate_ method in Python 3.11
https://docs.python.org/3/library/pickle.html#object.__getstate__
As a consequence, "else" statement is never hitted in this cycle:

# Get the object state.
if hasattr(value, "__get_pure_state__"):
state = value.__get_pure_state__()
elif hasattr(value, "__getstate__"):
state = value.__getstate__()
else:
state = value.__dict__

Kind Regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions