Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
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
1 change: 1 addition & 0 deletions Lib/test/test_opcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ def assert_races_do_not_crash(
# Reset:
if check_items:
for item in items:
_testinternalcapi.reset_version(item.__globals__) # Reset version to avoid overflow
item.__code__ = item.__code__.replace()
else:
read.__code__ = read.__code__.replace()
Expand Down
24 changes: 24 additions & 0 deletions Modules/_testinternalcapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2034,6 +2034,29 @@ gh_119213_getargs_impl(PyObject *module, PyObject *spam)
return Py_NewRef(spam);
}

/*[clinic input]
reset_version

dict: object(type="PyDictObject *", subclass_of="&PyDict_Type")

[clinic start generated code]*/

static PyObject *
reset_version_impl(PyObject *module, PyDictObject *dict)
/*[clinic end generated code: output=9ba372a8b7ed5566 input=212f6cc66caef7af]*/
{
PyInterpreterState *interp = _PyInterpreterState_GET();
PyDictKeysObject *dictkeys = dict->ma_keys;
if (dictkeys->dk_version != 0) {
Py_RETURN_NONE;
}
if (interp->dict_state.next_keys_version == 0) {
Py_RETURN_NONE;
}
interp->dict_state.next_keys_version = 1;
dictkeys->dk_version = 1;
Py_RETURN_NONE;
}

static PyMethodDef module_functions[] = {
{"get_configs", get_configs, METH_NOARGS},
Expand Down Expand Up @@ -2129,6 +2152,7 @@ static PyMethodDef module_functions[] = {
{"uop_symbols_test", _Py_uop_symbols_test, METH_NOARGS},
#endif
GH_119213_GETARGS_METHODDEF
RESET_VERSION_METHODDEF
{NULL, NULL} /* sentinel */
};

Expand Down
60 changes: 59 additions & 1 deletion Modules/clinic/_testinternalcapi.c.h

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