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-114314: ctypes: remove stgdict and switch to heap types #116458

Merged
merged 60 commits into from
Mar 20, 2024
Merged
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
6155211
Move paramfunc into a new struct, PyStgInfo
encukou Feb 16, 2024
0171c30
Move the StgInfo out of StgDictObject and into the classes themselves
encukou Feb 16, 2024
acd91e9
Move StgInfo init/retrieval right after the corresponding StgDict one
encukou Feb 19, 2024
55af504
Move `size` from StgDict to StgInfo
encukou Feb 19, 2024
27e5c50
Move `align` from StgDict to StgInfo
encukou Feb 19, 2024
01bc637
Move `length` from StgDict to StgInfo, except for sizeof calculation
encukou Feb 19, 2024
c8017e9
Move part of the sizeof calculation
encukou Feb 19, 2024
40b012f
Move `ffi_type_pointer` from StgDict to StgInfo
encukou Feb 19, 2024
537defb
Move `proto` from StgDict to StgInfo. Doesn't work just yet.
encukou Feb 20, 2024
ace6623
Hack: Reserve space for StgInfo in static type objects
encukou Feb 20, 2024
6f775b9
If StgInfo is not initialized, act as if it's not there
encukou Feb 20, 2024
4aaa06a
Move `getfunc` & `setfunc`
encukou Feb 20, 2024
6808524
Move `argtypes`
encukou Feb 20, 2024
f031c00
Move `converters`
encukou Feb 20, 2024
535176c
Move `restype`
encukou Feb 20, 2024
5260003
Move `checker`
encukou Feb 20, 2024
0d3017e
Move `flags`
encukou Feb 20, 2024
269b825
Move `format`
encukou Feb 20, 2024
946f474
Move `ndim`
encukou Feb 20, 2024
607ed23
Move `shape`
encukou Feb 21, 2024
cb126b7
Replace more uses of StgDict
encukou Feb 21, 2024
fd04c91
Don't pass dicts to PyCStgDict_clone
encukou Feb 21, 2024
8dce549
Don't set StgDict as type dict; use name `attrdict` for the type __di…
encukou Feb 21, 2024
6705e0e
Remove more uses of StgDict
encukou Feb 21, 2024
8f99377
Remove StgDict
encukou Feb 21, 2024
daea3e5
Remove StgDict from comments, names, and platform-specific code
encukou Feb 21, 2024
f67211f
Switch PyCSimpleType_new to _init
encukou Feb 23, 2024
02aa9e1
Switch _SimpleCData to a heap type
encukou Feb 23, 2024
13feac7
Convert Struct and Union type _new to _init
encukou Feb 23, 2024
a68417b
Switch PyCPointerType_new to _init
encukou Feb 23, 2024
ad5d7b4
Switch PyCFuncPtrType_new to _init
encukou Feb 23, 2024
8d5e230
Switch CFuncPtr to heap type
encukou Feb 23, 2024
cdfae13
Switch Array to heap type
encukou Feb 23, 2024
2d80960
Switch _Pointer to a heap type
encukou Feb 23, 2024
3337ba4
Switch _ctypes.Union to heap type
encukou Feb 23, 2024
596cb89
Switch Structure to heap type
encukou Feb 23, 2024
91feb64
Make the type-adding macros more regular
encukou Feb 23, 2024
77c64fe
Switch _CData to a heap type
encukou Feb 23, 2024
0be46a1
Visit/decref type in PyCData visit/dealloc
encukou Feb 23, 2024
9be3520
Remove _HackyHeapType
encukou Feb 23, 2024
e523c2f
Decref attrdicts
encukou Mar 1, 2024
fb70e43
Delegate CType_Type deallocation to PyType_Type.tp_dealloc
encukou Mar 5, 2024
cc59dea
Fix Windows-specific crashes
neonene Mar 5, 2024
9bd9eb1
Update comments
encukou Mar 6, 2024
946a0b1
Add tests for metaclass details
encukou Mar 6, 2024
970b41d
Fix getting the module state
encukou Mar 7, 2024
2a450ad
Add a blurb, even though this *should* not affect usage
encukou Mar 7, 2024
9878809
Apply suggestions from code review
encukou Mar 11, 2024
b2ba89a
Inline PyStgInfo_From* & PyStgInfo_Init for performance
encukou Mar 11, 2024
605c30c
Make CType_Type's clear & dealloc safer
encukou Mar 11, 2024
41dea1b
Remove self decrefs in error cases in init functions
encukou Mar 11, 2024
be0888f
Add `static` to PyType_Spec
encukou Mar 11, 2024
ac6eb38
Remove redundant comment
encukou Mar 11, 2024
33be37f
Apply suggestions from code review
encukou Mar 11, 2024
0b9d0a7
Fix comment
encukou Mar 12, 2024
f02bad6
PyErr_WriteUnraisable clears the exception
encukou Mar 12, 2024
16faac7
Call tp_init for argument validation
encukou Mar 20, 2024
2461e50
Add test for swapped type creation
neonene Mar 20, 2024
ab90768
Merge branch 'main' into ctypes-no-stgdict
encukou Mar 20, 2024
de054af
Fix test_swapped_type_creation
encukou Mar 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
If StgInfo is not initialized, act as if it's not there
  • Loading branch information
encukou committed Mar 7, 2024
commit 6f775b92f8c174da35996f1c76de1d54f15ceccc
4 changes: 2 additions & 2 deletions Modules/_ctypes/stgdict.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ _stginfo_from_type(ctypes_state *state, PyTypeObject *type, StgInfo **result)
}
StgInfo *info = PyObject_GetTypeData((PyObject *)type, state->PyCType_Type);
encukou marked this conversation as resolved.
Show resolved Hide resolved
if (!info->initialized) {
//PyErr_Format(PyExc_SystemError, "%R StgInfo is not initialized.", type);
//return -1;
// StgInfo is not initialized. This happens in abstract classes.
return 0;
}
*result = info;
return 1;
Expand Down