Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pickling or copying dynamic traits makes them loose their type and metadata. #2

Closed
chrisgorgo opened this issue Apr 27, 2011 · 4 comments · Fixed by #373
Closed

Pickling or copying dynamic traits makes them loose their type and metadata. #2

chrisgorgo opened this issue Apr 27, 2011 · 4 comments · Fixed by #373

Comments

@chrisgorgo
Copy link

pickling

a = HasTraits()
a.add_trait('foo', File(exists=True))
a.foo = Undefined

print a.traits()
print a.traits()['foo'].trait_type

inp = pickle.dumps(a, -1)
b = pickle.loads(inp)


print b.traits()
print b.traits()['foo'].trait_type

b.foo = 'idonotexist'
a.foo = 'idonotexist'

copying

In [68]: a = HasTraits()

In [69]: a.add_trait('foo', File(exists=True))

In [70]: a.foo = Undefined

In [71]: a.traits()['foo'].trait_type
Out[71]: <enthought.traits.trait_types.File object at 0x104809650>

In [72]: b = deepcopy(a)

In [73]: b.traits()['foo'].trait_type
Out[73]: <enthought.traits.trait_types.Python object at 0x10272b950>

In [74]: b.foo = 'idonotexist'

In [75]: a.foo = 'idonotexist'
@chrisgorgo
Copy link
Author

It's still there in 4.0.1

@bpteague
Copy link

FWIW, I'm also getting bitten by this in v4.5.0.

@stefanoborini
Copy link
Contributor

Verified also in 4.7.0

@mdickinson
Copy link
Member

mdickinson commented Apr 15, 2019

Regrettably, the fix for this in #373 had to be reverted in #462.

I'm leaving this issue closed, as it's mostly a duplicate of #16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants