Author bethard
Recipients
Date 2005-02-16.06:48:37
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
The current descrintro.html says:

"__new__ must return an object... If you return an
existing object, the constructor call will still call
its __init__ method. If you return an object of a
different class, its __init__ method will be called..."

This suggests that __new__ will call __init__ of the
object even if the object is a different type.  The
code in typeobject.c disagrees with this:

static PyObject *
type_call(PyTypeObject *type, PyObject *args, PyObject
*kwds)
{
	...
	/* If the returned object is not an instance of type,
	   it won't be initialized. */
	if (!PyType_IsSubtype(obj->ob_type, type))
		return obj;
	...
}

Suggested fix:

"__new__ must return an object... If you return an
existing object, the constructor call will still call
its __init__ method unless the object is an instance of
a different class..."
History
Date User Action Args
2008-01-20 09:57:30adminlinkissue1123716 messages
2008-01-20 09:57:30admincreate