Revert "Merge branch 'petrmitrichev-remove-function-local-statics'"

This reverts commit b8ed7759d5, reversing
changes made to 6f2399e86d.
This commit is contained in:
William S Fulton 2018-07-17 08:46:53 +01:00
commit 8e6799d783
3 changed files with 43 additions and 42 deletions

View file

@ -7,11 +7,6 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.0.0 (in progress)
===========================
2018-06-30: petrmitrichev
[Python] #1275 #1279 Remove function-local statics that call Python code
in order to avoid deadlocks with multi-threaded usage. These are now
file scope static variables and are initialized during module initialization.
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:

View file

@ -379,14 +379,6 @@ SWIG_init(void) {
assert(metatype);
#endif
#ifdef SWIG_PYTHON_BUILD_NONE
SWIG_Py_None_global = Py_BuildValue("");
Py_DECREF(SWIG_Py_None_global);
#endif
SWIG_This_global = SWIG_Python_str_FromChar("this");
SWIG_Python_TypeCache_global = PyDict_New();
/* Fix SwigMethods to carry the callback ptrs when needed */
SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);
@ -437,11 +429,8 @@ SWIG_init(void) {
SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name);
for (i = 0; swig_const_table[i].name != 0; ++i)
SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name);
#else
SwigPyObject_type_global = SwigPyObject_TypeOnce();
#endif
SwigPyPacked_type_global = SwigPyPacked_TypeOnce();
SWIG_InstallConstants(d,swig_const_table);
%}

View file

@ -210,6 +210,16 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
/* A functor is a function object with one single object argument */
#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, (char*)"O", obj);
/*
Helper for static pointer initialization for both C and C++ code, for example
static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...);
*/
#ifdef __cplusplus
#define SWIG_STATIC_POINTER(var) var
#else
#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var
#endif
/* -----------------------------------------------------------------------------
* Pointer declarations
* ----------------------------------------------------------------------------- */
@ -241,20 +251,26 @@ extern "C" {
# undef Py_None
# define Py_None SWIG_Py_None()
# endif
static PyObject *SWIG_Py_None_global = 0;
SWIGRUNTIME PyObject *
SWIG_Py_None(void) {
assert(SWIG_Py_None_global);
return SWIG_Py_None_global;
SWIGRUNTIMEINLINE PyObject *
_SWIG_Py_None(void)
{
PyObject *none = Py_BuildValue("");
Py_DECREF(none);
return none;
}
SWIGRUNTIME PyObject *
SWIG_Py_None(void)
{
static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None();
return none;
}
#endif
/* The python void return value */
SWIGRUNTIMEINLINE PyObject *
SWIG_Py_Void(void) {
SWIG_Py_Void(void)
{
PyObject *none = Py_None;
Py_INCREF(none);
return none;
@ -463,7 +479,6 @@ SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void);
#ifdef SWIGPYTHON_BUILTIN
static swig_type_info *SwigPyObject_stype = 0;
SWIGRUNTIME PyTypeObject*
SwigPyObject_type(void) {
SwigPyClientData *cd;
@ -474,12 +489,10 @@ SwigPyObject_type(void) {
return cd->pytype;
}
#else
static PyTypeObject *SwigPyObject_type_global = 0;
SWIGRUNTIME PyTypeObject*
SwigPyObject_type(void) {
assert(SwigPyObject_type_global);
return SwigPyObject_type_global;
static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce();
return type;
}
#endif
@ -823,12 +836,10 @@ SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w)
SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void);
static PyTypeObject* SwigPyPacked_type_global = 0;
SWIGRUNTIME PyTypeObject*
SwigPyPacked_type(void) {
assert(SwigPyPacked_type_global);
return SwigPyPacked_type_global;
static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce();
return type;
}
SWIGRUNTIMEINLINE int
@ -965,12 +976,20 @@ SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
* pointers/data manipulation
* ----------------------------------------------------------------------------- */
static PyObject *SWIG_This_global = NULL;
SWIGRUNTIMEINLINE PyObject *
_SWIG_This(void)
{
return SWIG_Python_str_FromChar("this");
}
static PyObject *swig_this = NULL;
SWIGRUNTIME PyObject *
SWIG_This(void) {
assert(SWIG_This_global);
return SWIG_This_global;
SWIG_This(void)
{
if (swig_this == NULL)
swig_this = _SWIG_This();
return swig_this;
}
/* #define SWIG_PYTHON_SLOW_GETSET_THIS */
@ -1399,7 +1418,7 @@ SWIG_Python_DestroyModule(PyObject *obj)
}
}
Py_DECREF(SWIG_This());
SWIG_This_global = NULL;
swig_this = NULL;
}
SWIGRUNTIME void
@ -1419,13 +1438,11 @@ SWIG_Python_SetModule(swig_module_info *swig_module) {
}
}
static PyObject *SWIG_Python_TypeCache_global = 0;
/* The python cached type query */
SWIGRUNTIME PyObject *
SWIG_Python_TypeCache(void) {
assert(SWIG_Python_TypeCache_global);
return SWIG_Python_TypeCache_global;
static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New();
return cache;
}
SWIGRUNTIME swig_type_info *