Skip to content

Commit 815b6ba

Browse files
committed
gh-148510: restore func_version check in _LOAD_ATTR_PROPERTY_FRAME
1 parent 9235de6 commit 815b6ba

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

Python/optimizer_bytecodes.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -240,19 +240,16 @@ dummy_func(void) {
240240
if (sym_matches_type_version(owner, type_version)) {
241241
ADD_OP(_NOP, 0, 0);
242242
} else {
243-
// add watcher so that whenever the type changes we invalidate this
244-
PyTypeObject *type = _PyType_LookupByVersion(type_version);
245-
// if the type is null, it was not found in the cache (there was a conflict)
246-
// with the key, in which case we can't trust the version
247-
if (type) {
248-
// if the type version was set properly, then add a watcher
249-
// if it wasn't this means that the type version was previously set to something else
250-
// and we set the owner to bottom, so we don't need to add a watcher because we must have
251-
// already added one earlier.
252-
if (sym_set_type_version(owner, type_version)) {
253-
PyType_Watch(TYPE_WATCHER_ID, (PyObject *)type);
254-
_Py_BloomFilter_Add(dependencies, type);
255-
}
243+
PyTypeObject *probable_type = sym_get_probable_type(owner);
244+
if (probable_type != NULL &&
245+
probable_type->tp_version_tag == type_version &&
246+
sym_set_type_version(owner, type_version)) {
247+
PyType_Watch(TYPE_WATCHER_ID, (PyObject *)probable_type);
248+
_Py_BloomFilter_Add(dependencies, probable_type);
249+
} else {
250+
ctx->contradiction = true;
251+
ctx->done = true;
252+
break;
256253
}
257254
}
258255
}

Python/optimizer_cases.c.h

Lines changed: 10 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)