8000 gh-112062: Make `_struct` module thread-safe in `--disable-gil` builds by chgnrdv · Pull Request #112094 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-112062: Make _struct module thread-safe in --disable-gil builds #112094

8000
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 2 commits into from
Nov 15, 2023
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
revert PyDict_GetItemWithError change in cache_struct_converter
  • Loading branch information
chgnrdv committed Nov 14, 2023
commit 4beec33f3ca407e11ef93b8dceebdcca8839ccb0
10 changes: 6 additions & 4 deletions Modules/_struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -2250,12 +2250,14 @@ cache_struct_converter(PyObject *module, PyObject *fmt, PyStructObject **ptr)
return 1;
}

if (PyDict_GetItemRef(state->cache, fmt, ptr) < 0) {
return 0;
}
if (*ptr != NULL) {
s_object = PyDict_GetItemWithError(state->cache, fmt);
if (s_object != NULL) {
*ptr = (PyStructObject *)Py_NewRef(s_object);
return Py_CLEANUP_SUPPORTED;
}
else if (PyErr_Occurred()) {
return 0;
}

s_object = PyObject_CallOneArg(state->PyStructType, fmt);
if (s_object != NULL) {
Expand Down
0