[3.13] gh-125243: Fix ZoneInfo data race in free threading build (GH-125281)#125414
Merged
colesbury merged 1 commit intopython:3.13from Oct 15, 2024
Merged
[3.13] gh-125243: Fix ZoneInfo data race in free threading build (GH-125281)#125414colesbury merged 1 commit intopython:3.13from
colesbury merged 1 commit intopython:3.13from
Conversation
…onGH-125281) Lock `ZoneInfoType` to protect accesses to `ZONEINFO_STRONG_CACHE`. Refactor the `tp_new` handler to use Argument Clinic so that we can just use `@critical_section` annotations on the relevant functions. Also use `PyDict_SetDefaultRef` instead of `PyDict_SetDefault` when inserting into the `TIMEDELTA_CACHE`. (cherry picked from commit f1d33db) Co-authored-by: Sam Gross <[email protected]>
This was referenced Oct 13, 2024
rruuaanng
approved these changes
Oct 14, 2024
rruuaanng
reviewed
Oct 14, 2024
| zoneinfo_ZoneInfo(PyTypeObject *type, PyObject *args, PyObject *kwargs) | ||
| { | ||
| PyObject *return_value = NULL; | ||
| #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
Contributor
There was a problem hiding this comment.
suggestion: Preprocessing maybe placed in the first column. This allows you to keep your style consistent with the other extension modules.
for example:
cpython/Modules/syslogmodule.c
Lines 234 to 244 in f1d33db
zoneinfo_ZoneInfo(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
PyObject *return_value = NULL;
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
Contributor
There was a problem hiding this comment.
This is a generated file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lock
ZoneInfoTypeto protect accesses toZONEINFO_STRONG_CACHE.Refactor the
tp_newhandler to use Argument Clinic so that we can justuse
@critical_sectionannotations on the relevant functions.Also use
PyDict_SetDefaultRefinstead ofPyDict_SetDefaultwheninserting into the
TIMEDELTA_CACHE.(cherry picked from commit f1d33db)
Co-authored-by: Sam Gross [email protected]