Bugs item #1123716, was opened at 2005-02-16 01:48 Message generated for change (Comment added) made by mcherm You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1123716&group_id=5470
Category: Documentation Group: None Status: Open Resolution: None Priority: 5 Submitted By: Steven Bethard (bediviere) Assigned to: Nobody/Anonymous (nobody) Summary: descrintro describes __new__ and __init__ behavior wrong Initial Comment: 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..." ---------------------------------------------------------------------- >Comment By: Michael Chermside (mcherm) Date: 2005-02-23 10:02 Message: Logged In: YES user_id=99874 I agree strongly that the docs need to be clarified. I spent a while playing around with it and confirmed that your reading of it appears to be correct, and your proposed wording is simple and straightforward. I second the request to make this change. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1123716&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com