diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2012-10-17 05:45:49 (GMT) |
---|---|---|
committer | Eric Snow <ericsnowcurrently@gmail.com> | 2012-10-17 05:45:49 (GMT) |
commit | 42da889fec6298debe216abac36dce9b87ed746d (patch) | |
tree | d361472e368b345b1099b5fa3a574767c17b68b5 /Objects | |
parent | 4d289a2a4d224948e490e0dc4ea807fa6aed3dec (diff) | |
parent | 547298c94cd491dbfaa7bc5f968c2bdcf91588cc (diff) | |
download | cpython-42da889fec6298debe216abac36dce9b87ed746d.zip cpython-42da889fec6298debe216abac36dce9b87ed746d.tar.gz cpython-42da889fec6298debe216abac36dce9b87ed746d.tar.bz2 |
merge for issue #16160: Subclass support now works for types.SimpleNamespace.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/namespaceobject.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/Objects/namespaceobject.c b/Objects/namespaceobject.c index 753874c..ff278d3 100644 --- a/Objects/namespaceobject.c +++ b/Objects/namespaceobject.c @@ -21,19 +21,19 @@ static PyMemberDef namespace_members[] = { static PyObject * namespace_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - _PyNamespaceObject *ns; - ns = PyObject_GC_New(_PyNamespaceObject, &_PyNamespace_Type); - if (ns == NULL) - return NULL; - - ns->ns_dict = PyDict_New(); - if (ns->ns_dict == NULL) { - Py_DECREF(ns); - return NULL; + PyObject *self; + + assert(type != NULL && type->tp_alloc != NULL); + self = type->tp_alloc(type, 0); + if (self != NULL) { + _PyNamespaceObject *ns = (_PyNamespaceObject *)self; + ns->ns_dict = PyDict_New(); + if (ns->ns_dict == NULL) { + Py_DECREF(ns); + return NULL; + } } - - PyObject_GC_Track(ns); - return (PyObject *)ns; + return self; } |