File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -512,7 +512,23 @@ def __setstate__(self, state):
512
512
super (BaseTraitedSpec , self ).__setstate__ (state )
513
513
514
514
class DynamicTraitedSpec (BaseTraitedSpec ):
515
- pass
515
+ """ A subclass to handle dynamic traits
516
+
517
+ This class is a workaround for add_traits and clone_traits not
518
+ functioning well together.
519
+ """
520
+ def __deepcopy__ (self , memo ):
521
+ """ bug in deepcopy for HasTraits results in weird cloning behavior for
522
+ added traits
523
+ """
524
+ id_self = id (self )
525
+ if id_self in memo :
526
+ return memo [id_self ]
527
+ dup_dict = deepcopy (self .__getstate__ (), memo )
528
+ dup = self .clone_traits (memo = memo )
529
+ dup .__setstate__ (dup_dict )
530
+ return dup
531
+
516
532
517
533
class TraitedSpec (BaseTraitedSpec ):
518
534
""" Create a subclass with strict traits.
You can’t perform that action at this time.
0 commit comments