gh-103092: Ensure _ctypes.c static types are accessed via global state#113857
gh-103092: Ensure _ctypes.c static types are accessed via global state#113857vstinner merged 5 commits intopython:mainfrom neonene:ctypes_ready
_ctypes.c static types are accessed via global state#113857Conversation
_ctypes.c static types are accessed via global state
|
@erlend-aasland, do you want to review these two PRs? |
Sure, I'll get to it later today. |
|
Done. I'll update this after #113620 is merged. |
_ctypes.c static types are accessed via global state_ctypes.c static types are accessed via global state
_ctypes.c static types are accessed via global state_ctypes.c static types are accessed via global state
|
I think this is ready for review. Sorry for mistakenly wiping out old commits (from web). Actual diff with a1ade06: Details--- Modules/_ctypes/_ctypes.c
+++ Modules/_ctypes/_ctypes.c
@@ -128,13 +128,6 @@
-static PyTypeObject UnionType_Type;
static PyTypeObject Union_Type;
static PyTypeObject Struct_Type;
static PyTypeObject Simple_Type;
ctypes_state global_state = {
.PyCStgDict_Type = &PyCStgDict_Type,
- .PyCStructType_Type = &PyCStructType_Type,
- .UnionType_Type = &UnionType_Type,
- .PyCPointerType_Type = &PyCPointerType_Type,
- .PyCArrayType_Type = &PyCArrayType_Type,
- .PyCSimpleType_Type = &PyCSimpleType_Type,
- .PyCFuncPtrType_Type = &PyCFuncPtrType_Type, |
|
Thanks, Victor! |
|
I merged this change which is a good start for futher work. I closed my similar duplicated (less complete) PR. |
This sets in place the
ctypes_state *st = GLOBAL_STATE()statements to make the coming PRs smaller. Suggested by @encukou: #113630 (comment)cc @erlend-aasland