Currently, these tests both fail on 2.7 and only the latter fails on 3.6.
@attr.s
class E1(Exception):
x = attr.ib()
y = attr.ib()
def test_exception_init_called():
e = E1(1, 2)
assert e.args == (e.x, e.y) == (1, 2)
def test_exception_init_called_even_with_kw():
e = E1(y=3, x=4)
assert e.args == (e.x, e.y) == (4, 3)
If attrs is overriding __init__ then this makes sense; args is filled in by __init__ in 2.x and __new__ in 3.x, but only pulling from the *args and never **kwargs. I discussed this a bit with @markrwilliams but I'm not sure what the best way to handle an attrs-ified exception would be. Maybe it's okay to consider args vestigal.
Mostly I'm raising this on the issue tracker because there are some references to using attrs for exceptions, but only indirectly. It'd be nice to have some documentation on a suggested approach either way.
Currently, these tests both fail on 2.7 and only the latter fails on 3.6.
If attrs is overriding
__init__then this makes sense;argsis filled in by__init__in 2.x and__new__in 3.x, but only pulling from the*argsand never**kwargs. I discussed this a bit with @markrwilliams but I'm not sure what the best way to handle an attrs-ified exception would be. Maybe it's okay to considerargsvestigal.Mostly I'm raising this on the issue tracker because there are some references to using attrs for exceptions, but only indirectly. It'd be nice to have some documentation on a suggested approach either way.