FredsFactory / FreeCAD_AirPlaneDesign

FreeCAD WorkBench Air Plane Design
GNU Lesser General Public License v2.1
79 stars 14 forks source link

[AirPlaneDesign] Python 3.11.x and above Json Fix for FreeCAD 0.21.2 … #47

Closed Syres916 closed 1 month ago

Syres916 commented 7 months ago

…and above

In order to fix errors using Python 3.11.x and above while preserving ability for Python 3.10.x and below to still work correctly, example error from another workbench:

  File "/usr/lib/python3.11/json/encoder.py", line 180, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
<class 'TypeError'>: Object of type FeaturePython is not JSON serializable
17:04:02  PropertyPythonObject::toString(): failed for <class 'SheetMetalCmd.SMViewProviderFlat'>
17:04:02  pyException: Traceback (most recent call last):
  File "/usr/lib/python3.11/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/encoder.py", line 200, in encode
    chunks = self.iterencode(o, _one_shot=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/encoder.py", line 258, in iterencode
    return _iterencode(o, 0)
           ^^^^^^^^^^^^^^^^^

Root Cause is https://github.com/FreeCAD/FreeCAD/commit/fbe2fef

Note: I am trying to contact the owner of CurvedShapes Wb as it's a dependency and therefore must be changed as well otherwise it's likely to still fail on saving the file.