@@ -454,20 +454,17 @@ class _ctypes.CType_Type "PyObject *" "clinic_state()->CType_Type"
454
454
static int
455
455
CType_Type_traverse (PyObject * self , visitproc visit , void * arg )
456
456
{
457
- ctypes_state * st = get_module_state_by_def_final (Py_TYPE (self ));
458
- if (st && st -> PyCType_Type ) {
459
- StgInfo * info ;
460
- if (PyStgInfo_FromType (st , self , & info ) < 0 ) {
461
- PyErr_WriteUnraisable (self );
462
- }
463
- if (info ) {
464
- Py_VISIT (info -> proto );
465
- Py_VISIT (info -> argtypes );
466
- Py_VISIT (info -> converters );
467
- Py_VISIT (info -> restype );
468
- Py_VISIT (info -> checker );
469
- Py_VISIT (info -> module );
470
- }
457
+ StgInfo * info = _PyStgInfo_FromType_NoState (self );
458
+ if (!info ) {
459
+ PyErr_WriteUnraisable (self );
460
+ }
461
+ if (info ) {
462
+ Py_VISIT (info -> proto );
463
+ Py_VISIT (info -> argtypes );
464
+ Py_VISIT (info -> converters );
465
+ Py_VISIT (info -> restype );
466
+ Py_VISIT (info -> checker );
467
+ Py_VISIT (info -> module );
471
468
}
472
469
Py_VISIT (Py_TYPE (self ));
473
470
return PyType_Type .tp_traverse (self , visit , arg );
@@ -488,38 +485,33 @@ ctype_clear_stginfo(StgInfo *info)
488
485
static int
489
486
CType_Type_clear (PyObject * self )
490
487
{
491
- ctypes_state * st = get_module_state_by_def_final (Py_TYPE (self ));
492
- if (st && st -> PyCType_Type ) {
493
- StgInfo * info ;
494
- if (PyStgInfo_FromType (st , self , & info ) < 0 ) {
495
- PyErr_WriteUnraisable (self );
496
- }
497
- if (info ) {
498
- ctype_clear_stginfo (info );
499
- }
488
+ StgInfo * info = _PyStgInfo_FromType_NoState (self );
489
+ if (!info ) {
490
+ PyErr_WriteUnraisable (self );
491
+ }
492
+ if (info ) {
493
+ ctype_clear_stginfo (info );
500
494
}
501
495
return PyType_Type .tp_clear (self );
502
496
}
503
497
504
498
static void
505
499
CType_Type_dealloc (PyObject * self )
506
500
{
507
- ctypes_state * st = get_module_state_by_def_final (Py_TYPE (self ));
508
- if (st && st -> PyCType_Type ) {
509
- StgInfo * info ;
510
- if (PyStgInfo_FromType (st , self , & info ) < 0 ) {
511
- PyErr_WriteUnraisable (self );
512
- }
513
- if (info ) {
514
- PyMem_Free (info -> ffi_type_pointer .elements );
515
- info -> ffi_type_pointer .elements = NULL ;
516
- PyMem_Free (info -> format );
517
- info -> format = NULL ;
518
- PyMem_Free (info -> shape );
519
- info -> shape = NULL ;
520
- ctype_clear_stginfo (info );
521
- }
501
+ StgInfo * info = _PyStgInfo_FromType_NoState (self );
502
+ if (!info ) {
503
+ PyErr_WriteUnraisable (self );
504
+ }
505
+ if (info ) {
506
+ PyMem_Free (info -> ffi_type_pointer .elements );
507
+ info -> ffi_type_pointer .elements = NULL ;
508
+ PyMem_Free (info -> format );
509
+ info -> format = NULL ;
510
+ PyMem_Free (info -> shape );
511
+ info -> shape = NULL ;
512
+ ctype_clear_stginfo (info );
522
513
}
514
+
523
515
PyTypeObject * tp = Py_TYPE (self );
524
516
PyType_Type .tp_dealloc (self );
525
517
Py_DECREF (tp );
@@ -5947,7 +5939,7 @@ module_free(void *module)
5947
5939
5948
5940
static PyModuleDef_Slot module_slots [] = {
5949
5941
{Py_mod_exec , _ctypes_mod_exec },
5950
- {Py_mod_multiple_interpreters , Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED },
5942
+ {Py_mod_multiple_interpreters , Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED },
5951
5943
{Py_mod_gil , Py_MOD_GIL_NOT_USED },
5952
5944
{0 , NULL }
5953
5945
};
0 commit comments