diff --git a/CHANGES.current b/CHANGES.current index 9fb57f9f0..2e5d368a5 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-07-17: petrmitrichev,wsfulton + [Python] #1275 #1279 Initialize function-local statics (singletons) that call Python + code during Python module initialization in order to avoid deadlocks with subsequent + multi-threaded usage. + 2018-06-15: wsfulton [Python] Fix seg fault using Python 2 when passing a Python string, containing invalid utf-8 content, to a wstring or wchar * parameter. A TypeError is thrown instead, eg: diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 7ef70585f..516cd628b 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -379,6 +379,17 @@ SWIG_init(void) { assert(metatype); #endif + /* Create singletons now to avoid potential deadlocks with multi-threaded usage after module initialization */ +#ifdef SWIG_PYTHON_BUILD_NONE + SWIG_Py_None(); +#endif + SWIG_This(); + SWIG_Python_TypeCache(); + SwigPyPacked_type(); +#ifndef SWIGPYTHON_BUILTIN + SwigPyObject_type(); +#endif + /* Fix SwigMethods to carry the callback ptrs when needed */ SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);