Skip to content

gh-103092: Ensure _ctypes.c static types are accessed via global state - #113857

Merged
vstinner merged 5 commits into
python:mainfrom
neonene:ctypes_ready
Jan 22, 2024
Merged

gh-103092: Ensure _ctypes.c static types are accessed via global state#113857
vstinner merged 5 commits into
python:mainfrom
neonene:ctypes_ready

Conversation

@neonene

@neoneneneonene commented Jan 9, 2024

Copy link
Copy Markdown
Contributor

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

@bedevere-appbedevere-appBot mentioned this pull request Jan 9, 2024
25 tasks
@neoneneneonene changed the title gh-103092: Ensure '_ctypes.c' static types are accessed via global stategh-103092: Ensure _ctypes.c static types are accessed via global stateJan 9, 2024
@erlend-aasland

Copy link
Copy Markdown
Contributor

See also ongoing work by @aisk in #113620. Perhaps you could coordinate your efforts?

@encukou

Copy link
Copy Markdown
Member

@erlend-aasland, do you want to review these two PRs?
If you merge one I'll be happy to resolve the conflicts on the other one.

@erlend-aasland

Copy link
Copy Markdown
Contributor

@erlend-aasland, do you want to review these two PRs? If you merge one I'll be happy to resolve the conflicts on the other one.

Sure, I'll get to it later today.

@erlend-aaslanderlend-aasland self-assigned this Jan 10, 2024
Comment threadModules/_ctypes/callbacks.c Outdated
@neonene

Copy link
Copy Markdown
ContributorAuthor

Done. I'll update this after #113620 is merged.

@neoneneneonene closed this Jan 18, 2024
@neoneneneonene changed the title gh-103092: Ensure _ctypes.c static types are accessed via global stateEnsure _ctypes.c static types are accessed via global stateJan 18, 2024
@neoneneneonene reopened this Jan 18, 2024
@neoneneneonene changed the title Ensure _ctypes.c static types are accessed via global stategh-103092: Ensure _ctypes.c static types are accessed via global stateJan 18, 2024
@neonene

Copy link
Copy Markdown
ContributorAuthor

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,

Comment threadModules/_ctypes/ctypes.h
@erlend-aasland

Copy link
Copy Markdown
Contributor

Thanks, Victor!

@vstinner

Copy link
Copy Markdown
Member

I merged this change which is a good start for futher work. I closed my similar duplicated (less complete) PR.

@neonene
neonene deleted the ctypes_ready branch January 22, 2024 17:49
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@neonene@erlend-aasland@encukou@vstinner@aisk