8000 GH-100000: Cleanup and polish various watchers code by itamaro · Pull Request #99998 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-100000: Cleanup and polish various watchers code #99998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 14, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Replace invariant test with assert in type watchers notification
  • Loading branch information
itamaro committed Dec 5, 2022
commit 8e2e17a4fe748dddf4b7f900bef650814f6b894e
7 changes: 4 additions & 3 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,23 +485,24 @@ PyType_Modified(PyTypeObject *type)
}
}

// Notify registered type watchers, if any
if (type->tp_watched) {
PyInterpreterState *interp = _PyInterpreterState_GET();
int bits = type->tp_watched;
int i = 0;
while(bits && i < TYPE_MAX_WATCHERS) {
while (bits) {
assert(i < TYPE_MAX_WATCHERS);
if (bits & 1) {
PyType_WatchCallback cb = interp->type_watchers[i];
if (cb && (cb(type) < 0)) {
PyErr_WriteUnraisable((PyObject *)type);
}
}
i += 1;
i++;
bits >>= 1;
}
}


type->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;
type->tp_version_tag = 0; /* 0 is not a valid version tag */
}
Expand Down
0