◐ Shell
clean mode source ↗

Message 148845 - Python tracker

> > Is the following change in behavior caused by the fix for this issue?
> > 
> > $ python3.2 -c $'class A(IOError):\n  def __init__(self, arg): pass\nA(arg=1)'
> > $ python3.3 -c $'class A(IOError):\n  def __init__(self, arg): pass\nA(arg=1)'
> > Traceback (most recent call last):
> >   File "<string>", line 3, in <module>
> > TypeError: A does not take keyword arguments
> 
> It must be because IOError now has a significant __new__ method.
> I could change it to accept arbitrary arguments but I'm not sure that's
> the right solution.
> Another approach would be:
> - if IOError is instantiated, initialize stuff in IOError.__new__
> - otherwise, initialize stuff in IOError.__init__

To make things clearer, IOError.__new__ would detect if a subclass is
asked for, and then defer initialization until __init__ is called so
that argument checking is done in __init__.