diff options
author | Guido van Rossum <guido@python.org> | 2002-04-06 01:05:01 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2002-04-06 01:05:01 (GMT) |
commit | 8ace1ab53a49d90d66e8a03491a272c70ad4eb46 (patch) | |
tree | d08f5976ad3e74100608cade6362c0ad41be1099 /Objects | |
parent | 181e41ad4064cc94b9f41ce49ee541a132f93615 (diff) | |
download | cpython-8ace1ab53a49d90d66e8a03491a272c70ad4eb46.zip cpython-8ace1ab53a49d90d66e8a03491a272c70ad4eb46.tar.gz cpython-8ace1ab53a49d90d66e8a03491a272c70ad4eb46.tar.bz2 |
- 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]
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/typeobject.c | 4 |
1 files changed, 4 insertions, 0 deletions
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 @@ type_call(PyTypeObject *type, PyObject *args, PyObject *kwds) (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) { |