View Issue Details

IDProjectCategoryView StatusLast Update
0001083FreeCADBugpublic2013-04-23 21:54
Reportercrashfridh Assigned To 
PrioritynormalSeverityblockReproducibilityalways
Status closedResolutionnot fixable 
Summary0001083: Methods added to FeaturePython objects are not restored
DescriptionA method added to a FeaturePython object is not restored after saving and loading.
TagsNo tags attached.
FreeCAD Information

Activities

2013-04-05 03:28

 

savingmethods.py (Attachment missing)

wmayer

2013-04-05 09:49

administrator   ~0003044

This is technically not possible because functions cannot be serialized.

Example:
import json
def test():
   print "Hello, World!"

test()
s=json.dumps(test)

Error:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib/python2.7/json/encoder.py", line 201, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python2.7/json/encoder.py", line 264, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python2.7/json/encoder.py", line 178, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <function test at 0x88f3224> is not JSON serializable


So, again it's up to the Python programmer to do that in __getstate__ and __setstate__

yorik

2013-04-23 21:53

administrator   ~0003104

I assume this bug report can be closed?

yorik

2013-04-23 21:54

administrator   ~0003105

oops it is closed already.

Issue History

Date Modified Username Field Change
2013-04-05 03:28 crashfridh New Issue
2013-04-05 03:28 crashfridh File Added: savingmethods.py
2013-04-05 09:49 wmayer Note Added: 0003044
2013-04-05 09:50 wmayer Resolution open => not fixable
2013-04-23 21:53 yorik Note Added: 0003104
2013-04-23 21:54 yorik Note Added: 0003105
2013-04-23 21:54 yorik Status new => closed