Use different capsule names with and without -builtin

Types generated with and without -builtin are not compatible. Mixing
them in a common type list leads to crashes. Avoid this by using
different capsule names: "type_pointer_capsule" without -builtin and
"type_pointer_capsule_builtin" with.

See #1684
This commit is contained in:
Eugene Toder 2022-03-18 00:08:01 -04:00
commit f733efd3c0
9 changed files with 51 additions and 4 deletions

View file

@ -1686,7 +1686,7 @@ SWIG_Python_SetModule(swig_module_info *swig_module) {
#endif
PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule);
if (pointer && module) {
if (PyModule_AddObject(module, "type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer) == 0) {
if (PyModule_AddObject(module, SWIGPY_CAPSULE_ATTR_NAME, pointer) == 0) {
Swig_Capsule_global = pointer;
} else {
Py_DECREF(pointer);