enthought / enthought/traits

TraitError when doing |= on a Set.

Open
#359 4 comments 0 reactions 0 assignees View on GitHub
topic: traits listener rework type: bug
Dominant language
Python
Stars
462
Forks
90
PR merge metrics
No merged PRs in 30d

Description

The following appears to be a regression since Traits 4.5.0.

```
(test)bash-3.2$ cat traits_bug.py
from traits.api import Either, HasTraits, Int, Set, Str

class A(HasTraits):
maybe_set = Either(Set(Int), None)

a = A(maybe_set = {1, 2, 3})
a.maybe_set |= {4, 5, 6}

(test)bash-3.2$ python traits_bug.py
Traceback (most recent call last):
File "traits_bug.py", line 7, in
a.maybe_set |= {4, 5, 6}
File "/Users/mdickinson/.edm/envs/test/lib/python2.7/site-packages/traits/trait_handlers.py", line 2896, in __ior__
self.update(value)
File "/Users/mdickinson/.edm/envs/test/lib/python2.7/site-packages/traits/trait_handlers.py", line 2775, in update
raise excp
traits.trait_errors.TraitError: Each element of the 'maybe_set_items' trait of an A instance must be a TraitListEvent or None, but a value of was specified.
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.