enthought / enthought/traits

Confused pop method in "Either(None, Dict)" trait.

Open
#278 1 comment 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
Python
Stars
462
Forks
90
PR merge metrics
No merged PRs in 30d

Description

On a trait that can be either `None` or a dictionary, the `pop` method seems to be generating strange results:

```
Python 2.7.10 |Master 2.1.0.dev1829 (64-bit)| (default, Oct 21 2015, 09:09:19)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.6)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from traits.api import *
>>> class A(HasTraits):
... foo = Either(None, Dict)
...
>>> a = A()
>>> a.foo = {'a': 1, 'bb': 2}
>>> a.foo.pop('a')
Traceback (most recent call last):
File "", line 1, in
File "build/bdist.macosx-10.6-x86_64/egg/traits/trait_handlers.py", line 3180, in pop
File "build/bdist.macosx-10.6-x86_64/egg/traits/trait_handlers.py", line 3056, in _send_trait_items_event
File "build/bdist.macosx-10.6-x86_64/egg/traits/trait_handlers.py", line 172, in error
traits.trait_errors.TraitError: The 'foo_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.