mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
- 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]
This commit is contained in:
parent
181e41ad40
commit
8ace1ab53a
3 changed files with 30 additions and 0 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue