open-research / sumatra

http://neuralensemble.org/sumatra/
BSD 2-Clause "Simplified" License
127 stars 48 forks source link

Fix: Fix logic in `project.save()` for Python 3.11+ #396

Open alcrene opened 5 months ago

alcrene commented 5 months ago

Now all objects define __getstate__ (with default value None)

Previous logic in project.save() would test for existence of that method, and if present, use it to populate a state variable. This no longer works, because a None value passes the first test (it exists) but it is obviously not callable. This small patch adds support for Python 3.11+ by also checking that __getstate__ is not None before attempting to call it.