diff options
author | Bram Moolenaar <Bram@vim.org> | 2005-06-13 22:28:56 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2005-06-13 22:28:56 +0000 |
commit | 9ba0eb850c0f4c94df3b7f7461610bf0b073f712 (patch) | |
tree | 11638af8ad8ecdfd337a6db15914b2e2cdff3aea /src/if_python.c | |
parent | bac97eb8ae6b067466cab0481cac2f25b335ffe7 (diff) |
updated for version 7.0084v7.0084
Diffstat (limited to 'src/if_python.c')
-rw-r--r-- | src/if_python.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/src/if_python.c b/src/if_python.c index b799047e9f..8aca83518a 100644 --- a/src/if_python.c +++ b/src/if_python.c @@ -384,10 +384,13 @@ static int initialised = 0; #if PYTHON_API_VERSION < 1007 /* Python 1.4 */ typedef PyObject PyThreadState; -#endif /* Python 1.4 */ +#endif -#ifndef PY_CAN_RECURSE +#ifdef PY_CAN_RECURSE +static PyGILState_STATE pygilstate = PyGILState_UNLOCKED; +#else static PyThreadState *saved_python_thread = NULL; +#endif /* * Suspend a thread of the Python interpreter, other threads are allowed to @@ -396,7 +399,11 @@ static PyThreadState *saved_python_thread = NULL; static void Python_SaveThread(void) { +#ifdef PY_CAN_RECURSE + PyGILState_Release(pygilstate); +#else saved_python_thread = PyEval_SaveThread(); +#endif } /* @@ -406,10 +413,13 @@ Python_SaveThread(void) static void Python_RestoreThread(void) { +#ifdef PY_CAN_RECURSE + pygilstate = PyGILState_Ensure(); +#else PyEval_RestoreThread(saved_python_thread); saved_python_thread = NULL; -} #endif +} /* * obtain a lock on the Vim data structures @@ -430,11 +440,17 @@ python_end() { #ifdef DYNAMIC_PYTHON if (hinstPython && Py_IsInitialized()) + { + Python_RestoreThread(); /* enter python */ Py_Finalize(); + } end_dynamic_python(); #else if (Py_IsInitialized()) + { + Python_RestoreThread(); /* enter python */ Py_Finalize(); + } #endif } @@ -470,11 +486,7 @@ Python_Init(void) goto fail; /* the first python thread is vim's, release the lock */ -#ifdef PY_CAN_RECURSE - PyEval_SaveThread(); -#else Python_SaveThread(); -#endif initialised = 1; } @@ -497,9 +509,7 @@ fail: static void DoPythonCommand(exarg_T *eap, const char *cmd) { -#ifdef PY_CAN_RECURSE - PyGILState_STATE pygilstate; -#else +#ifndef PY_CAN_RECURSE static int recursive = 0; #endif #if defined(MACOS) && !defined(MACOS_X_UNIX) @@ -544,19 +554,11 @@ DoPythonCommand(exarg_T *eap, const char *cmd) } #endif -#ifdef PY_CAN_RECURSE - pygilstate = PyGILState_Ensure(); -#else Python_RestoreThread(); /* enter python */ -#endif PyRun_SimpleString((char *)(cmd)); -#ifdef PY_CAN_RECURSE - PyGILState_Release(pygilstate); -#else Python_SaveThread(); /* leave python */ -#endif #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) if (saved_locale != NULL) |