New submission from Armin Ronacher <armin.ronac...@active-4.com>: 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: http://dev.pocoo.org/projects/werkzeug/browser/werkzeug/contrib/iterio.py ---------- messages: 82497 nosy: aronacher severity: normal status: open title: Python 2.6 object.__new__ argument calling autodetection faulty type: behavior versions: Python 2.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5322> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com