Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RobotError: Correctly initialize exception message
Regression introduced by 788b3fd. While setting self.message is documented for setting user-defined exceptions, it might be a misunderstanding by me and it's *not* about the printed result of the exception but about setting custom attributes for an exception. After digging a bit deeper on this, I found that both Python 2.7 and 3.x simply accumulate all arguments passed to __init__() to self.args, see: https://github.com/python/cpython/blob/2.7/Objects/exceptions.c#L65 https://github.com/python/cpython/blob/3.6/Objects/exceptions.c#L66 Testing this with the following example leads to the expected result: class Foo(Exception): def __init__(self): super(Foo, self).__init__(111, "bar") raise Foo() Result for Python 2.7.13: Traceback (most recent call last): File "exctest.py", line 5, in <module> raise Foo() __main__.Foo: (111, 'bar') Result for Python 3.6.1: Traceback (most recent call last): File "exctest.py", line 5, in <module> raise Foo() __main__.Foo: (111, 'bar') So the self.args attribute is just passed to repr() and/or str() and that's about it. Signed-off-by: aszlig <aszlig@redmoonstudios.org> Issue: #23 Cc: @nh2
- Loading branch information