Skip to content
Open
4 changes: 2 additions & 2 deletions Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2906,6 +2906,7 @@ dummy_func(

macro(LOAD_ATTR_CLASS) =
unused/1 +
_RECORD_TOS +
_CHECK_ATTR_CLASS +
unused/2 +
_LOAD_ATTR_CLASS +
Expand Down
21 changes: 6 additions & 15 deletions Python/optimizer_bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ dummy_func(void) {
}

op(_CHECK_ATTR_CLASS, (type_version/2, owner -- owner)) {
PyObject *type = (PyObject *)_PyType_LookupByVersion(type_version);
if (type) {
PyObject *type = sym_get_probable_value(owner);
if (type != NULL && ((PyTypeObject *)type)->tp_version_tag == type_version) {
if (type == sym_get_const(ctx, owner)) {
ADD_OP(_NOP, 0, 0);
Copy link
Copy Markdown
Member

@Fidget-Spinner Fidget-Spinner Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, It think this is bugged on main, there needs to be a watcher installed on the type for this path similar to _GUARD_TYPE_VERSION. would you like to open a PR to fix it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! Which issue should I link to?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I think it's fine to open a new issue describing the bug.

}
Expand All @@ -236,19 +236,10 @@ dummy_func(void) {
if (sym_matches_type_version(owner, type_version)) {
ADD_OP(_NOP, 0, 0);
} else {
// add watcher so that whenever the type changes we invalidate this
PyTypeObject *type = _PyType_LookupByVersion(type_version);
// if the type is null, it was not found in the cache (there was a conflict)
// with the key, in which case we can't trust the version
if (type) {
// if the type version was set properly, then add a watcher
// if it wasn't this means that the type version was previously set to something else
// and we set the owner to bottom, so we don't need to add a watcher because we must have
// already added one earlier.
if (sym_set_type_version(owner, type_version)) {
PyType_Watch(TYPE_WATCHER_ID, (PyObject *)type);
_Py_BloomFilter_Add(dependencies, type);
}
PyTypeObject *probable_type = sym_get_probable_type(owner);
if (probable_type->tp_version_tag == type_version && sym_set_type_version(owner, type_version)) {
PyType_Watch(TYPE_WATCHER_ID, (PyObject *)probable_type);
_Py_BloomFilter_Add(dependencies, probable_type);
}
}
}
Expand Down
14 changes: 6 additions & 8 deletions Python/optimizer_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions Python/record_functions.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading