When building with both Python 2 and Python 3 don't use RTLD_GLOBAL, so that
both may work.
diff --git a/src/if_python.c b/src/if_python.c
index c7c67a8..8a28f8b 100644
--- a/src/if_python.c
+++ b/src/if_python.c
@@ -93,32 +93,38 @@
# define PY_CAN_RECURSE
#endif
-#if defined(DYNAMIC_PYTHON) || defined(PROTO)
-# ifndef DYNAMIC_PYTHON
-# define HINSTANCE long_u /* for generating prototypes */
-# endif
+# if defined(DYNAMIC_PYTHON) || defined(PROTO)
+# ifndef DYNAMIC_PYTHON
+# define HINSTANCE long_u /* for generating prototypes */
+# endif
-#ifndef WIN3264
-# include <dlfcn.h>
-# define FARPROC void*
-# define HINSTANCE void*
-# define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL)
-# define close_dll dlclose
-# define symbol_from_dll dlsym
-#else
-# define load_dll LoadLibrary
-# define close_dll FreeLibrary
-# define symbol_from_dll GetProcAddress
-#endif
+# ifndef WIN3264
+# include <dlfcn.h>
+# define FARPROC void*
+# define HINSTANCE void*
+# ifdef FEAT_PYTHON3
+ /* Don't use RTLD_GLOBAL, it may cause a crash if both :python and :py3 are
+ * used. But without it importing may fail, e.g., for termios. */
+# define load_dll(n) dlopen((n), RTLD_LAZY)
+# else
+# define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL)
+# endif
+# define close_dll dlclose
+# define symbol_from_dll dlsym
+# else
+# define load_dll LoadLibrary
+# define close_dll FreeLibrary
+# define symbol_from_dll GetProcAddress
+# endif
/* This makes if_python.c compile without warnings against Python 2.5
* on Win32 and Win64. */
-#undef PyRun_SimpleString
-#undef PyArg_Parse
-#undef PyArg_ParseTuple
-#undef Py_BuildValue
-#undef Py_InitModule4
-#undef Py_InitModule4_64
+# undef PyRun_SimpleString
+# undef PyArg_Parse
+# undef PyArg_ParseTuple
+# undef Py_BuildValue
+# undef Py_InitModule4
+# undef Py_InitModule4_64
/*
* Wrapper defines
@@ -345,6 +351,7 @@
{
int i;
+#if 0 /* this should be OK now that we don't use RTLD_GLOBAL */
#if defined(UNIX) && defined(FEAT_PYTHON3)
/* Can't have Python and Python3 loaded at the same time, it may cause a
* crash. */
@@ -354,6 +361,7 @@
return FAIL;
}
#endif
+#endif
if (hinstPython)
return OK;