Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bf4cc5d

Browse files
author
Thomas Heller
committed
Fix issue6869: refcount problem in the _ctypes extension.
1 parent 39d795d commit bf4cc5d

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

Misc/NEWS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ Core and Builtins
2424
Extensions
2525
----------
2626

27-
- Issue #5504 - ctypes should now work with systems where mmap can't
27+
- Issue #6869: Fix a refcount problem in the _ctypes extension.
28+
29+
- Issue #5504: ctypes should now work with systems where mmap can't
2830
be PROT_WRITE and PROT_EXEC.
2931

3032
- Issue #9507: Named tuple repr will now automatically display the right

Modules/_ctypes/_ctypes.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5312,36 +5312,42 @@ PyInit__ctypes(void)
53125312
Struct_Type.tp_base = &PyCData_Type;
53135313
if (PyType_Ready(&Struct_Type) < 0)
53145314
return NULL;
5315+
Py_INCREF(&Struct_Type);
53155316
PyModule_AddObject(m, "Structure", (PyObject *)&Struct_Type);
53165317

53175318
Py_TYPE(&Union_Type) = &UnionType_Type;
53185319
Union_Type.tp_base = &PyCData_Type;
53195320
if (PyType_Ready(&Union_Type) < 0)
53205321
return NULL;
5322+
Py_INCREF(&Union_Type);
53215323
PyModule_AddObject(m, "Union", (PyObject *)&Union_Type);
53225324

53235325
Py_TYPE(&PyCPointer_Type) = &PyCPointerType_Type;
53245326
PyCPointer_Type.tp_base = &PyCData_Type;
53255327
if (PyType_Ready(&PyCPointer_Type) < 0)
53265328
return NULL;
5329+
Py_INCREF(&PyCPointer_Type);
53275330
PyModule_AddObject(m, "_Pointer", (PyObject *)&PyCPointer_Type);
53285331

53295332
Py_TYPE(&PyCArray_Type) = &PyCArrayType_Type;
53305333
PyCArray_Type.tp_base = &PyCData_Type;
53315334
if (PyType_Ready(&PyCArray_Type) < 0)
53325335
return NULL;
5336+
Py_INCREF(&PyCArray_Type);
53335337
PyModule_AddObject(m, "Array", (PyObject *)&PyCArray_Type);
53345338

53355339
Py_TYPE(&Simple_Type) = &PyCSimpleType_Type;
53365340
Simple_Type.tp_base = &PyCData_Type;
53375341
if (PyType_Ready(&Simple_Type) < 0)
53385342
return NULL;
5343+
Py_INCREF(&Simple_Type);
53395344
PyModule_AddObject(m, "_SimpleCData", (PyObject *)&Simple_Type);
53405345

53415346
Py_TYPE(&PyCFuncPtr_Type) = &PyCFuncPtrType_Type;
53425347
PyCFuncPtr_Type.tp_base = &PyCData_Type;
53435348
if (PyType_Ready(&PyCFuncPtr_Type) < 0)
53445349
return NULL;
5350+
Py_INCREF(&PyCFuncPtr_Type);
53455351
PyModule_AddObject(m, "CFuncPtr", (PyObject *)&PyCFuncPtr_Type);
53465352

53475353
/*************************************************

0 commit comments

Comments
 (0)