diff --git a/.github/workflows/test-with-pip.yml b/.github/workflows/test-with-pip.yml index 35004508..38ceb699 100644 --- a/.github/workflows/test-with-pip.yml +++ b/.github/workflows/test-with-pip.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ['3.7', '3.8', '3.9', '3.10'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] runs-on: ${{ matrix.os }} diff --git a/apptools/persistence/state_pickler.py b/apptools/persistence/state_pickler.py index 079dcd63..6857e7f5 100644 --- a/apptools/persistence/state_pickler.py +++ b/apptools/persistence/state_pickler.py @@ -393,11 +393,14 @@ def _do_instance(self, value): args = value.__getinitargs__() # Get the object state. + state = None if hasattr(value, "__get_pure_state__"): state = value.__get_pure_state__() elif hasattr(value, "__getstate__"): + # Note that __getstate__() may return None in Python >= 3.11 state = value.__getstate__() - else: + + if state is None: state = value.__dict__ state.pop("__traits_version__", None) diff --git a/docs/releases/upcoming/328.bugfix.rst b/docs/releases/upcoming/328.bugfix.rst new file mode 100644 index 00000000..f55976de --- /dev/null +++ b/docs/releases/upcoming/328.bugfix.rst @@ -0,0 +1 @@ +Fix StatePickler for Python 3.11. (#328) \ No newline at end of file