From a2992fe42e0a462dc9c08bbffa29c6b4fdbd07ff Mon Sep 17 00:00:00 2001 From: benjamin-sch Date: Tue, 8 Feb 2022 09:04:18 +0100 Subject: [PATCH] always get the type_pointer from capsule instead of using a static variable as the value may change after re-initilization/due to subinterpreters --- Lib/python/pyrun.swg | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index d42dc0f0f..2aef3ad0f 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1627,19 +1627,19 @@ SWIG_Python_TypeCache(void) { SWIGRUNTIME swig_module_info * SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { +#ifdef SWIG_LINK_RUNTIME static void *type_pointer = (void *)0; /* first check if module already created */ if (!type_pointer) { -#ifdef SWIG_LINK_RUNTIME type_pointer = SWIG_ReturnGlobalTypeList((void *)0); -#else - type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); - if (PyErr_Occurred()) { - PyErr_Clear(); - type_pointer = (void *)0; - } -#endif } +#else + void *type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); + if (PyErr_Occurred()) { + PyErr_Clear(); + type_pointer = (void *)0; + } +#endif return (swig_module_info *) type_pointer; }