Bugs item #1123716, was opened at 2005-02-15 23:48
Message generated for change (Tracker Item Submitted) made by Item Submitter
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..."

----------------------------------------------------------------------

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

Reply via email to