This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author aronacher
Recipients aronacher
Date 2009-02-19.20:34:22
SpamBayes Score 2.66827e-07
Marked as misclassified No
Message-id <>
In 2.6 a deprecation warning was added if `object.__new__` was called
with arguments.  Per se this is fine, but the detection seems to be faulty.

The following code shows the problem:

>>> class A(object):
...     def __new__(self):
...         raise TypeError('i do not exist')
>>> class B(A):
...     __new__ = object.__new__
...     def __init__(self, x):
...         self.x = x
>>> B(1)
__main__:1: DeprecationWarning: object.__new__() takes no parameters
<__main__.B object at 0x88dd0>

In the `B` case `__new__` is not overridden (in the sense that it
differs from object.__new__) but `__init__` is.  Which is the default
behaviour.  Nonetheless a warning is raised.

I used the pattern with the "__new__ switch" to achieve a
cStringIO.StringIO behavior that supports typechecks:  IterIO() returns
either a IterI or IterO object, both instances of IterIO so that
typechecks can be performed.

Real-world use case here:
Date User Action Args
2009-02-19 20:34:25aronachersetrecipients: + aronacher
2009-02-19 20:34:25aronachersetmessageid: <>
2009-02-19 20:34:23aronacherlinkissue5322 messages
2009-02-19 20:34:22aronachercreate