possible minor bug in trait_notifiers.py

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

possible minor bug in trait_notifiers.py

Alexander Held
Hi,

consider the following example (traits version 4.2.1):


from traits.api import HasTraits, Int

class Foo(HasTraits):
     x = Int

     def _x_changed(self):
         raise RuntimeError

Foo().x = 5


this produces the unexpected output:


Traceback (most recent call last):
   File "scratch.py", line 9, in <module>
     Foo().x = 5
   File "/home/aheld/src/ets/traits/traits/trait_notifiers.py", line
351, in __call__
     getattr(self, self.call_method)(object, trait_name, old, new)
   File "/home/aheld/src/ets/traits/traits/trait_notifiers.py", line
368, in call_1
     handle_exception( object, trait_name, old, new )
   File "/home/aheld/src/ets/traits/traits/trait_notifiers.py", line
175, in _handle_exception
     handler_info.handler( object, trait_name, old, new )
   File "/home/aheld/src/ets/traits/traits/trait_notifiers.py", line
228, in _log_exception
     (excp.args[0] == 'maximum recursion depth exceeded')):
IndexError: tuple index out of range



since len(excp.args) == 0.
Raising RuntimeError('Foo Message') works as expected.
Although an uncommon use case, someone might want to know about it.


Alexander


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: possible minor bug in trait_notifiers.py

Robert Kern
On Tue, Sep 4, 2012 at 10:13 AM, Alexander Held
<[hidden email]> wrote:

> Hi,
>
> consider the following example (traits version 4.2.1):
>
>
> from traits.api import HasTraits, Int
>
> class Foo(HasTraits):
>      x = Int
>
>      def _x_changed(self):
>          raise RuntimeError
>
> Foo().x = 5
>
>
> this produces the unexpected output:
>
>
> Traceback (most recent call last):
>    File "scratch.py", line 9, in <module>
>      Foo().x = 5
>    File "/home/aheld/src/ets/traits/traits/trait_notifiers.py", line
> 351, in __call__
>      getattr(self, self.call_method)(object, trait_name, old, new)
>    File "/home/aheld/src/ets/traits/traits/trait_notifiers.py", line
> 368, in call_1
>      handle_exception( object, trait_name, old, new )
>    File "/home/aheld/src/ets/traits/traits/trait_notifiers.py", line
> 175, in _handle_exception
>      handler_info.handler( object, trait_name, old, new )
>    File "/home/aheld/src/ets/traits/traits/trait_notifiers.py", line
> 228, in _log_exception
>      (excp.args[0] == 'maximum recursion depth exceeded')):
> IndexError: tuple index out of range
>
>
>
> since len(excp.args) == 0.
> Raising RuntimeError('Foo Message') works as expected.
> Although an uncommon use case, someone might want to know about it.

Thanks! I have a PR to fix this:

https://github.com/enthought/traits/pull/28

--
Robert Kern
Enthought
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: possible minor bug in trait_notifiers.py

Chris Colbert
merged

On Wed, Sep 5, 2012 at 4:45 AM, Robert Kern <[hidden email]> wrote:
On Tue, Sep 4, 2012 at 10:13 AM, Alexander Held
<[hidden email]> wrote:
> Hi,
>
> consider the following example (traits version 4.2.1):
>
>
> from traits.api import HasTraits, Int
>
> class Foo(HasTraits):
>      x = Int
>
>      def _x_changed(self):
>          raise RuntimeError
>
> Foo().x = 5
>
>
> this produces the unexpected output:
>
>
> Traceback (most recent call last):
>    File "scratch.py", line 9, in <module>
>      Foo().x = 5
>    File "/home/aheld/src/ets/traits/traits/trait_notifiers.py", line
> 351, in __call__
>      getattr(self, self.call_method)(object, trait_name, old, new)
>    File "/home/aheld/src/ets/traits/traits/trait_notifiers.py", line
> 368, in call_1
>      handle_exception( object, trait_name, old, new )
>    File "/home/aheld/src/ets/traits/traits/trait_notifiers.py", line
> 175, in _handle_exception
>      handler_info.handler( object, trait_name, old, new )
>    File "/home/aheld/src/ets/traits/traits/trait_notifiers.py", line
> 228, in _log_exception
>      (excp.args[0] == 'maximum recursion depth exceeded')):
> IndexError: tuple index out of range
>
>
>
> since len(excp.args) == 0.
> Raising RuntimeError('Foo Message') works as expected.
> Although an uncommon use case, someone might want to know about it.

Thanks! I have a PR to fix this:

https://github.com/enthought/traits/pull/28

--
Robert Kern
Enthought
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev