You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The PrefixMap trait type turns some incorrect types (like list) into TraitErrors, but not others (like complex). Since the value of a PrefixMap trait is supposed to be a string, we should apply the same up-front validation as in BaseStr.
>>> from traits.api import *
>>> class A(HasTraits):
... foo = PrefixMap({"yes": 1, "no": 0})
...
>>> a = A()
>>> a.foo = "yes"
>>> a.foo = 1j
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/mdickinson/Enthought/ETS/traits/traits/trait_types.py", line 2911, in validate
n = len(value)
TypeError: object of type 'complex' has no len()
The text was updated successfully, but these errors were encountered:
The
PrefixMap
trait type turns some incorrect types (likelist
) intoTraitError
s, but not others (likecomplex
). Since the value of aPrefixMap
trait is supposed to be a string, we should apply the same up-front validation as inBaseStr
.The text was updated successfully, but these errors were encountered: