realthunder / FreeCAD

Link branch FreeCAD
Other
763 stars 45 forks source link

[Problem] <class 'TypeError'>: Object of type FeaturePython is not JSON serializable #927

Closed kevenwyld closed 7 months ago

kevenwyld commented 8 months ago

Is there an existing issue for this?

Version

0.21 (Development)

Full version info

OS: Ubuntu Core 20 (sway/sway)
Word size of FreeCAD: 64-bit
Version: 2024.104.0.38929 (Git) Snap 124
Build type: Release
Branch: tag: 20240104stable
Hash: 975453f6aa33093edbcc835760d7a65123059b98
Python 3.8.10, Qt 5.15.7, Coin 4.0.1, Vtk 7.1.1, OCC 7.6.3
Locale: English/United States (en_US)
Installed mods: 
  * Assembly3 0.12.0
  * Curves 0.6.15
  * fasteners 0.4.71

Subproject(s) affected?

Fastners v0.4.70 (specifically the error seems to be related to <class 'FastenersCmd.FSViewProviderTree'>)

Problem description

During saving, or during autosave, I receive the following error. It doesn't seem to impact anything, and saved files work just fine.

12:33:34  PropertyPythonObject::toString(): failed for <class 'FastenersCmd.FSViewProviderTree'>
12:33:34  Traceback (most recent call last):
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/__init__.py", line 234, in dumps
    return cls(
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
<class 'TypeError'>: Object of type FeaturePython is not JSON serializable
12:33:34  PropertyPythonObject::toString(): failed for <class 'FastenersCmd.FSViewProviderTree'>
12:33:34  Traceback (most recent call last):
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/__init__.py", line 234, in dumps
    return cls(
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
<class 'TypeError'>: Object of type FeaturePython is not JSON serializable
12:34:45  PropertyPythonObject::toString(): failed for <class 'FastenersCmd.FSViewProviderTree'>
12:34:45  Traceback (most recent call last):
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/__init__.py", line 234, in dumps
    return cls(
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
<class 'TypeError'>: Object of type FeaturePython is not JSON serializable
12:34:45  PropertyPythonObject::toString(): failed for <class 'FastenersCmd.FSViewProviderTree'>
12:34:45  Traceback (most recent call last):
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/__init__.py", line 234, in dumps
    return cls(
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/snap/freecad-realthunder/124/usr/lib/python3.8/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
<class 'TypeError'>: Object of type FeaturePython is not JSON serializable
12:34:45  Save AutoRecovery file: Needed time: 923ms

Anything else?

No response

Code of Conduct

kevenwyld commented 8 months ago

Looks like this was fixed upstream maybe https://github.com/shaise/FreeCAD_FastenersWB/issues/297 and https://github.com/FreeCAD/FreeCAD/issues/10460

We are merged with upstream on 2023.05.22 though so we don't have this fix yet.