Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BUG: fix stringdtype singleton thread safety#28864

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
charris merged 2 commits intonumpy:maintenance/2.2.xfromcharris:backport-28862
Apr 29, 2025
Merged
Changes fromall 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
14 changes: 11 additions & 3 deletionsnumpy/_core/src/multiarray/stringdtype/dtype.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -633,11 +633,16 @@ PyArray_Descr *
stringdtype_finalize_descr(PyArray_Descr *dtype)
{
PyArray_StringDTypeObject *sdtype = (PyArray_StringDTypeObject *)dtype;
// acquire the allocator lock in case the descriptor we want to finalize
// is shared between threads, see gh-28813
npy_string_allocator *allocator = NpyString_acquire_allocator(sdtype);
if (sdtype->array_owned == 0) {
sdtype->array_owned = 1;
NpyString_release_allocator(allocator);
Py_INCREF(dtype);
return dtype;
}
NpyString_release_allocator(allocator);
PyArray_StringDTypeObject *ret = (PyArray_StringDTypeObject *)new_stringdtype_instance(
sdtype->na_object, sdtype->coerce);
ret->array_owned = 1;
Expand DownExpand Up@@ -852,14 +857,17 @@ init_string_dtype(void)
return -1;
}

PyArray_Descr *singleton =
NPY_DT_CALL_default_descr(&PyArray_StringDType);
PyArray_StringDTypeObject *singleton =
(PyArray_StringDTypeObject *)NPY_DT_CALL_default_descr(&PyArray_StringDType);

if (singleton == NULL) {
return -1;
}

PyArray_StringDType.singleton = singleton;
// never associate the singleton with an array
singleton->array_owned = 1;

PyArray_StringDType.singleton = (PyArray_Descr *)singleton;
PyArray_StringDType.type_num = NPY_VSTRING;

for (int i = 0; PyArray_StringDType_casts[i] != NULL; i++) {
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp