Mailing List Archive

python/dist/src/Objects typeobject.c,2.126.4.23,2.126.4.24
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv14033/Objects

Modified Files:
Tag: release22-maint
typeobject.c
Log Message:
Backport, at the reqest of Kevin Jacobs:

- Changed new-style class instantiation so that when C's __new__
method returns something that's not a C instance, its __init__ is
not called. [SF bug #537450]

XXX This is arguably a semantic change, but it's hard to imagine a
reason for wanting to depend on the old behavior. If problems with
this are reported within a week of the release of 2.2.2 beta 1, we may
revert this change.


Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.126.4.23
retrieving revision 2.126.4.24
diff -C2 -d -r2.126.4.23 -r2.126.4.24
*** typeobject.c 14 Aug 2002 17:36:26 -0000 2.126.4.23
--- typeobject.c 7 Oct 2002 18:08:27 -0000 2.126.4.24
***************
*** 190,193 ****
--- 190,197 ----
(PyDict_Check(kwds) && PyDict_Size(kwds) == 0)))
return obj;
+ /* If the returned object is not an instance of type,
+ it won't be initialized. */
+ if (!PyType_IsSubtype(obj->ob_type, type))
+ return obj;
type = obj->ob_type;
if (PyType_HasFeature(type, Py_TPFLAGS_HAVE_CLASS) &&