Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Jan 22, 2024
Merged

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

merged 5 commits into from
Jan 22, 2024

Conversation

neonene
Copy link
Contributor

@neonene neonene commented Jan 9, 2024

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-app bedevere-app bot mentioned this pull request Jan 9, 2024
25 tasks
@neonene neonene changed the title gh-103092: Ensure '_ctypes.c' static types are accessed via global state gh-103092: Ensure _ctypes.c static types are accessed via global state Jan 9, 2024
@erlend-aasland
Copy link
Contributor

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

@encukou
Copy link
Member

encukou commented Jan 10, 2024

@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
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-aasland erlend-aasland self-assigned this Jan 10, 2024
@neonene
Copy link
Contributor Author

neonene commented Jan 17, 2024

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

@neonene neonene closed this Jan 18, 2024
@neonene neonene changed the title gh-103092: Ensure _ctypes.c static types are accessed via global state Ensure _ctypes.c static types are accessed via global state Jan 18, 2024
@neonene neonene reopened this Jan 18, 2024
@neonene neonene changed the title Ensure _ctypes.c static types are accessed via global state gh-103092: Ensure _ctypes.c static types are accessed via global state Jan 18, 2024
@neonene
Copy link
Contributor Author

neonene commented Jan 18, 2024

I think this is ready for review. Sorry for mistakenly wiping out old commits (from web).

Actual diff with a1ade06:

--- 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,

@vstinner vstinner merged commit 9f7176d into python:main Jan 22, 2024
31 checks passed
@erlend-aasland
Copy link
Contributor

Thanks, Victor!

@vstinner
Copy link
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 free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants