-
Notifications
You must be signed in to change notification settings - Fork 11
Closed
Description
As seen in the test failures in #25 , with the new traits release (5.0.0), pickling MultiContext instances is broken on Python 2. The specific test that fails is multi_context_test_case
To reproduce the error, run
from io import BytesIO
from codetools.contexts.data_context import DataContext
from codetools.contexts.multi_context import MultiContext
dc1=DataContext(name='temp1', subcontext={'a': 1})
dc2 = DataContext(name='temp2', subcontext={'b': 2})
mc = MultiContext(dc1, dc2, name='woah')
f = BytesIO()
dc1.save(f) # works as expected
mc.save(f) # fails with the traceback seen below
ERROR: Checking if the data persists correctly when saving and loading back
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/home/travis/build/enthought/codetools/codetools/contexts/tests/multi_context_test_case.py", line 126, in test_persistence
m.save(f)
File "/home/travis/build/enthought/codetools/codetools/contexts/data_context.py", line 227, in save
sweet_pickle.dump(self, file_object, 1)
File "/home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/apptools/sweet_pickle/__init__.py", line 131, in dump
return d(obj, file, protocol)
File "/home/travis/virtualenv/python2.7.14/lib/python2.7/copy_reg.py", line 70, in _reduce_ex
raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle instancemethod objects
----------------------------------------------------------------------
The underlying cause of this error is the traits PR enthought/traits#373 which fixed an earlier issue with pickling dynamically added traits.
Also see #25 (comment) for further insight into the issue.
Note that this is a known issue with the upcoming 4.3.0 release of codetools on Python 2.
Metadata
Metadata
Assignees
Labels
No labels