- 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]
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 71d22f3..51ed430 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -169,6 +169,10 @@
(kwds == NULL ||
(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 (type->tp_init != NULL &&
type->tp_init(obj, args, kwds) < 0) {