[issue5322] Python 2.6 object.__new__ argument calling autodetection faulty

Trundle report at bugs.python.org
Tue Mar 24 21:25:11 CET 2009


Trundle <andysmuell at hammerhartes.de> added the comment:

I think the real problem here is `update_one_slot` and not `object_new`. It
is impossible to set "__new__" to a PyCFunction inside Python code, which
may be a feature, but is in fact very irritating.

For example the following snippet:

>>> class Dict(dict): __new__ = object.__new__
...
>>> Dict.__new__ is object.__new__
True
>>> Dict()
{}

I would rather expect this behaviour (or at least that Dict.__new__ is not
object.__new__):

>>> Dict.__new__ is object.__new__
True
>>> Dict()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: object.__new__(Dict) is not safe, use dict.__new__()

The attached patch leads to that behaviour, which also fixes the argument
calling autodetection of `object.__new__`.

----------
keywords: +patch
nosy: +Trundle
Added file: http://bugs.python.org/file13408/update_one_slot.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5322>
_______________________________________


More information about the Python-bugs-list mailing list