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

Appearance settings

Commit 28e476f

Browse filesBrowse files
gh-127945: make initialization of error_object_name thread safe in ctypes (#131896)
1 parent bc5a028 commit 28e476f
Copy full SHA for 28e476f

File tree

Expand file treeCollapse file tree

2 files changed

+8
-8
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+8
-8
lines changed

‎Modules/_ctypes/_ctypes.c

Copy file name to clipboardExpand all lines: Modules/_ctypes/_ctypes.c
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6093,14 +6093,19 @@ _ctypes_mod_exec(PyObject *mod)
60936093
}
60946094

60956095
#ifdef WORDS_BIGENDIAN
6096-
st->swapped_suffix = PyUnicode_InternFromString("_le");
6096+
st->swapped_suffix = PyUnicode_InternFromString("_le");
60976097
#else
6098-
st->swapped_suffix = PyUnicode_InternFromString("_be");
6098+
st->swapped_suffix = PyUnicode_InternFromString("_be");
60996099
#endif
61006100
if (st->swapped_suffix == NULL) {
61016101
return -1;
61026102
}
61036103

6104+
st->error_object_name = PyUnicode_InternFromString("ctypes.error_object");
6105+
if (st->error_object_name == NULL) {
6106+
return -1;
6107+
}
6108+
61046109
if (_ctypes_add_types(mod) < 0) {
61056110
return -1;
61066111
}

‎Modules/_ctypes/callproc.c

Copy file name to clipboardExpand all lines: Modules/_ctypes/callproc.c
+1-6Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,7 @@ _ctypes_get_errobj(ctypes_state *st, int **pspace)
164164
"cannot get thread state");
165165
return NULL;
166166
}
167-
if (st->error_object_name == NULL) {
168-
st->error_object_name = PyUnicode_InternFromString("ctypes.error_object");
169-
if (st->error_object_name == NULL) {
170-
return NULL;
171-
}
172-
}
167+
assert(st->error_object_name != NULL);
173168
if (PyDict_GetItemRef(dict, st->error_object_name, &errobj) < 0) {
174169
return NULL;
175170
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.