Python initialization code tidy up

I've moved the initialization of statics a little earlier on - a little
safer as it is hard to follow exactly when some of these were being
used, such as SWIG_Py_None which sometimes replaces Py_None.
This commit is contained in:
William S Fulton 2018-06-30 19:18:06 +01:00
commit 4b4e0180f4
3 changed files with 24 additions and 67 deletions

View file

@ -379,6 +379,14 @@ 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);
@ -429,13 +437,11 @@ 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
SWIG_Py_None_global_Init();
SwigPyObject_type_global_Init();
SwigPyPacked_type_global_Init();
SWIG_Python_TypeCache_global_Init();
SwigPyPacked_type_global = SwigPyPacked_TypeOnce();
SWIG_InstallConstants(d,swig_const_table);
%}