summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-03-17 20:57:17 (GMT)
committerBenjamin Peterson <benjamin@python.org>2014-03-17 20:57:17 (GMT)
commitdf813791db32867634c86c33714995dfeb651099 (patch)
treeb4498a4b2bc2e5cd95f0746ec9f51b7180db6935 /Objects
parent0b1be1a3b12c7da952b6452973ad88ae3ef3705a (diff)
downloadcpython-df813791db32867634c86c33714995dfeb651099.zip
cpython-df813791db32867634c86c33714995dfeb651099.tar.gz
cpython-df813791db32867634c86c33714995dfeb651099.tar.bz2
correct the fix for #20637; allow slot descriptor inheritance to take place before creating cached keys
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index df8f351..c21b397 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -2472,12 +2472,6 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
type->tp_dictoffset = slotoffset;
slotoffset += sizeof(PyObject *);
}
- else if (!type->tp_dictoffset) {
- type->tp_dictoffset = base->tp_dictoffset;
- }
- if (type->tp_dictoffset) {
- et->ht_cached_keys = _PyDict_NewKeysForClass();
- }
if (add_weak) {
assert(!base->tp_itemsize);
type->tp_weaklistoffset = slotoffset;
@@ -2527,6 +2521,10 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
/* Put the proper slots in place */
fixup_slot_dispatchers(type);
+ if (type->tp_dictoffset) {
+ et->ht_cached_keys = _PyDict_NewKeysForClass();
+ }
+
Py_DECREF(dict);
return (PyObject *)type;
@@ -2643,9 +2641,6 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
type->tp_doc = tp_doc;
}
}
- if (type->tp_dictoffset) {
- res->ht_cached_keys = _PyDict_NewKeysForClass();
- }
if (type->tp_dealloc == NULL) {
/* It's a heap type, so needs the heap types' dealloc.
subtype_dealloc will call the base type's tp_dealloc, if
@@ -2656,6 +2651,10 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
if (PyType_Ready(type) < 0)
goto fail;
+ if (type->tp_dictoffset) {
+ res->ht_cached_keys = _PyDict_NewKeysForClass();
+ }
+
/* Set type.__module__ */
s = strrchr(spec->name, '.');
if (s != NULL)