enthought/enaml — Issue #67: BUG: Entering -1 in the 'age' field of the 'person' example raises an exception.
Author: WarrenWeckesser
Created: 2012-01-09 22:14:38+00:00
State: open

Run the 'person' example and enter -1 for the age. I get this exception:

Exception occurred in traits notification handler.
Please check the log file for details.
Exception occurred in traits notification handler for object: , trait: value, old value: 0, new value: -1
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/traits/trait_notifiers.py", line 511, in rebind_call_0
self.dispatch( getattr( self.object(), self.name ) )
File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/traits/trait_notifiers.py", line 454, in dispatch
handler( *args )
File "/Users/warren/local/lib/python2.7/site-packages/enaml-0.1a-py2.7.egg/enaml/expressions.py", line 490, in update_expression
new_val = self.eval_setter()
File "/Users/warren/local/lib/python2.7/site-packages/enaml-0.1a-py2.7.egg/enaml/expressions.py", line 498, in eval_setter
return eval(self.setter_code, self.f_globals, scope)
File "/Users/warren/gitwork/enaml/examples/person/person_view.enaml", line 21, in
value := person.age
File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/traits/trait_handlers.py", line 170, in error
value )
TraitError: The 'age' trait of a Person instance must be an integer >= 0, but a value of -1 was specified.

I would expect the field to just turn red. Presumably, the problem is that the enaml widget (corresponding to an IntField) doesn't know about the lower limit of the trait, so it allows -1.