File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -1194,7 +1194,7 @@ P_get(void *ptr, Py_ssize_t size)
11941194
11951195/* Table with info about all formats.
11961196 * Must be accessed via _ctypes_get_fielddesc, which initializes it on
1197- * first use.
1197+ * first use. After initialization it's treated as constant & read-only.
11981198 */
11991199
12001200struct formattable {
@@ -1464,12 +1464,14 @@ _Py_COMP_DIAG_POP
14641464struct fielddesc *
14651465_ctypes_get_fielddesc (const char * fmt )
14661466{
1467- static int initialized = 0 ;
1467+ static bool initialized = 0 ;
1468+ static PyMutex mutex = {0 };
1469+ PyMutex_Lock (& mutex );
14681470 if (!initialized ) {
14691471 _ctypes_init_fielddesc ();
1470-
14711472 initialized = 1 ;
14721473 }
1474+ PyMutex_Unlock (& mutex );
14731475 struct fielddesc * result = NULL ;
14741476 switch (fmt [0 ]) {
14751477/*[python input]
You can’t perform that action at this time.
0 commit comments