summaryrefslogtreecommitdiff
path: root/Python/specialize.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/specialize.c')
-rw-r--r--Python/specialize.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/Python/specialize.c b/Python/specialize.c
index dd5b22dd23..9187438d51 100644
--- a/Python/specialize.c
+++ b/Python/specialize.c
@@ -1330,16 +1330,16 @@ _Py_Specialize_BinarySubscr(
SPECIALIZATION_FAIL(BINARY_SUBSCR, SPEC_FAIL_WRONG_NUMBER_ARGUMENTS);
goto fail;
}
- assert(cls->tp_version_tag != 0);
- write_u32(cache->type_version, cls->tp_version_tag);
- int version = _PyFunction_GetVersionForCurrentState(func);
- if (version == 0 || version != (uint16_t)version) {
- SPECIALIZATION_FAIL(BINARY_SUBSCR, version == 0 ?
- SPEC_FAIL_OUT_OF_VERSIONS : SPEC_FAIL_OUT_OF_RANGE);
+ uint32_t version = _PyFunction_GetVersionForCurrentState(func);
+ if (version == 0) {
+ SPECIALIZATION_FAIL(BINARY_SUBSCR, SPEC_FAIL_OUT_OF_VERSIONS);
goto fail;
}
- cache->func_version = version;
- ((PyHeapTypeObject *)container_type)->_spec_cache.getitem = descriptor;
+ PyHeapTypeObject *ht = (PyHeapTypeObject *)container_type;
+ // This pointer is invalidated by PyType_Modified (see the comment on
+ // struct _specialization_cache):
+ ht->_spec_cache.getitem = descriptor;
+ ht->_spec_cache.getitem_version = version;
instr->op.code = BINARY_SUBSCR_GETITEM;
goto success;
}