mertemba/structstore

Handle __getstate__ in python 3.11

Closed this issue · 0 comments

Add __getstate__ method to deal with default __getstate__ implementation and avoid crash:

Traceback (most recent call last):                                                                                                                                                      
  File "/home/ruof/Projects/aduulm_sandbox/colcon_build/install/imdash/lib/python3.12/site-packages/imdash/views/view_object.py", line 52, in render                                    
    res = render_func(obj, name, ctx=self, **self.params)                                                                                                                               
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                               
  File "/home/ruof/Projects/aduulm_sandbox/colcon_build/install/trajectory_planning/lib/python3.12/site-packages/tpl/gui/state_and_params.py", line 114, in render_planners             
    save_planning_params(s)                                                                                                                                                             
  File "/home/ruof/Projects/aduulm_sandbox/colcon_build/install/trajectory_planning/lib/python3.12/site-packages/tpl/application/planning_app.py", line 131, in save_planning_params    
    otb.save(params, abs_path)                                                                                                                                                          
  File "/usr/local/lib/python3.12/dist-packages/objtoolbox/storage.py", line 408, in save                                                                                               
    rep = ser.serialize(obj)                                                                                                                                                            
          ^^^^^^^^^^^^^^^^^^                                                                                                                                                            
  File "/usr/local/lib/python3.12/dist-packages/objtoolbox/storage.py", line 231, in serialize                                                                                          
    val = self.serialize(v, k, parent=obj)                                                                                                                                              
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                              
  File "/usr/local/lib/python3.12/dist-packages/objtoolbox/storage.py", line 231, in serialize                                                                                          
    val = self.serialize(v, k, parent=obj)                                                                                                                                              
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                              
  File "/usr/local/lib/python3.12/dist-packages/objtoolbox/storage.py", line 207, in serialize                                                                                          
    attrs = obj.__getstate__()                                                                                                                                                          
            ^^^^^^^^^^^^^^^^^^                                                                                                                                                          
  File "/usr/lib/python3.12/copyreg.py", line 136, in _slotnames                                                                                                                        
    for name in slots:                                                                                                                                                                  
TypeError: 'property' object is not iterable