homepage

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 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

AltStyle によって変換されたページ (->オリジナル) /