-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix cloning issue with container traits (#1624)
This PR makes a shallow fix for problems with `clone_traits` applied to `List`, `Dict` and `Set` traits. It doesn't try to touch deeper issues of disconnection of `TraitsListObject`, `TraitDictObject` and friends from their owning `HasTraits` object. Closes #1622. The cause of that issue is that we were [using a function](https://github.com/enthought/traits/blob/c8bd6e5f332d44b512b79f0bee3cb814b9125352/traits/trait_list_object.py#L815) `lambda: None` for `object` where a `HasTraits` object was expected. Inside `TraitListObject` we then [take a weakref](https://github.com/enthought/traits/blob/c8bd6e5f332d44b512b79f0bee3cb814b9125352/traits/trait_list_object.py#L572) to that function. In most cases, the `lambda` function has no other references to it, so it's garbage collected immediately and when the weakref is dereferenced, it returns `None`. But in the deepcopy case the weakref target is kept alive for long enough that we try to use the actual `lambda: None` function as a `HasTraits` object. The solution is to allow and special-case an object of `None` in the `TraitListObject` constructor. Co-authored-by: Steve Allen <sallen@enthought.com>
- Loading branch information
1 parent
c8bd6e5
commit a307f57
Showing
7 changed files
with
78 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters