forked from aniani/vim
updated for version 7.3.956
Problem: Python vim.bindeval() causes SIGABRT. Solution: Make pygilstate a local variable. (Yukihiro Nakadaira)
This commit is contained in:
@@ -1298,7 +1298,14 @@ FunctionCall(PyObject *self, PyObject *argsObject, PyObject *kwargs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Py_BEGIN_ALLOW_THREADS
|
||||||
|
Python_Lock_Vim();
|
||||||
|
|
||||||
error = func_call(name, &args, selfdict, &rettv);
|
error = func_call(name, &args, selfdict, &rettv);
|
||||||
|
|
||||||
|
Python_Release_Vim();
|
||||||
|
Py_END_ALLOW_THREADS
|
||||||
|
|
||||||
if (error != OK)
|
if (error != OK)
|
||||||
{
|
{
|
||||||
result = NULL;
|
result = NULL;
|
||||||
|
@@ -676,11 +676,8 @@ static int SetBufferLineList(buf_T *, PyInt, PyInt, PyObject *, PyInt *);
|
|||||||
typedef PyObject PyThreadState;
|
typedef PyObject PyThreadState;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PY_CAN_RECURSE
|
#ifndef PY_CAN_RECURSE
|
||||||
static PyGILState_STATE pygilstate = PyGILState_UNLOCKED;
|
|
||||||
#else
|
|
||||||
static PyThreadState *saved_python_thread = NULL;
|
static PyThreadState *saved_python_thread = NULL;
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Suspend a thread of the Python interpreter, other threads are allowed to
|
* Suspend a thread of the Python interpreter, other threads are allowed to
|
||||||
@@ -689,11 +686,7 @@ static PyThreadState *saved_python_thread = NULL;
|
|||||||
static void
|
static void
|
||||||
Python_SaveThread(void)
|
Python_SaveThread(void)
|
||||||
{
|
{
|
||||||
#ifdef PY_CAN_RECURSE
|
|
||||||
PyGILState_Release(pygilstate);
|
|
||||||
#else
|
|
||||||
saved_python_thread = PyEval_SaveThread();
|
saved_python_thread = PyEval_SaveThread();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -703,13 +696,10 @@ Python_SaveThread(void)
|
|||||||
static void
|
static void
|
||||||
Python_RestoreThread(void)
|
Python_RestoreThread(void)
|
||||||
{
|
{
|
||||||
#ifdef PY_CAN_RECURSE
|
|
||||||
pygilstate = PyGILState_Ensure();
|
|
||||||
#else
|
|
||||||
PyEval_RestoreThread(saved_python_thread);
|
PyEval_RestoreThread(saved_python_thread);
|
||||||
saved_python_thread = NULL;
|
saved_python_thread = NULL;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
python_end()
|
python_end()
|
||||||
@@ -725,14 +715,22 @@ python_end()
|
|||||||
#ifdef DYNAMIC_PYTHON
|
#ifdef DYNAMIC_PYTHON
|
||||||
if (hinstPython && Py_IsInitialized())
|
if (hinstPython && Py_IsInitialized())
|
||||||
{
|
{
|
||||||
|
# ifdef PY_CAN_RECURSE
|
||||||
|
PyGILState_Ensure();
|
||||||
|
# else
|
||||||
Python_RestoreThread(); /* enter python */
|
Python_RestoreThread(); /* enter python */
|
||||||
|
# endif
|
||||||
Py_Finalize();
|
Py_Finalize();
|
||||||
}
|
}
|
||||||
end_dynamic_python();
|
end_dynamic_python();
|
||||||
#else
|
#else
|
||||||
if (Py_IsInitialized())
|
if (Py_IsInitialized())
|
||||||
{
|
{
|
||||||
|
# ifdef PY_CAN_RECURSE
|
||||||
|
PyGILState_Ensure();
|
||||||
|
# else
|
||||||
Python_RestoreThread(); /* enter python */
|
Python_RestoreThread(); /* enter python */
|
||||||
|
# endif
|
||||||
Py_Finalize();
|
Py_Finalize();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -837,6 +835,9 @@ DoPythonCommand(exarg_T *eap, const char *cmd, typval_T *rettv)
|
|||||||
#if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
|
#if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
|
||||||
char *saved_locale;
|
char *saved_locale;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef PY_CAN_RECURSE
|
||||||
|
PyGILState_STATE pygilstate;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef PY_CAN_RECURSE
|
#ifndef PY_CAN_RECURSE
|
||||||
if (recursive)
|
if (recursive)
|
||||||
@@ -881,7 +882,11 @@ DoPythonCommand(exarg_T *eap, const char *cmd, typval_T *rettv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PY_CAN_RECURSE
|
||||||
|
pygilstate = PyGILState_Ensure();
|
||||||
|
#else
|
||||||
Python_RestoreThread(); /* enter python */
|
Python_RestoreThread(); /* enter python */
|
||||||
|
#endif
|
||||||
|
|
||||||
if (rettv == NULL)
|
if (rettv == NULL)
|
||||||
PyRun_SimpleString((char *)(cmd));
|
PyRun_SimpleString((char *)(cmd));
|
||||||
@@ -905,7 +910,11 @@ DoPythonCommand(exarg_T *eap, const char *cmd, typval_T *rettv)
|
|||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PY_CAN_RECURSE
|
||||||
|
PyGILState_Release(pygilstate);
|
||||||
|
#else
|
||||||
Python_SaveThread(); /* leave python */
|
Python_SaveThread(); /* leave python */
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
|
#if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
|
||||||
if (saved_locale != NULL)
|
if (saved_locale != NULL)
|
||||||
|
@@ -699,8 +699,6 @@ static PyObject *Py3Init_vim(void);
|
|||||||
* 1. Python interpreter main program.
|
* 1. Python interpreter main program.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static PyGILState_STATE pygilstate = PyGILState_UNLOCKED;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
python3_end()
|
python3_end()
|
||||||
{
|
{
|
||||||
@@ -718,7 +716,7 @@ python3_end()
|
|||||||
if (Py_IsInitialized())
|
if (Py_IsInitialized())
|
||||||
{
|
{
|
||||||
// acquire lock before finalizing
|
// acquire lock before finalizing
|
||||||
pygilstate = PyGILState_Ensure();
|
PyGILState_Ensure();
|
||||||
|
|
||||||
Py_Finalize();
|
Py_Finalize();
|
||||||
}
|
}
|
||||||
@@ -826,6 +824,7 @@ DoPy3Command(exarg_T *eap, const char *cmd, typval_T *rettv)
|
|||||||
#endif
|
#endif
|
||||||
PyObject *cmdstr;
|
PyObject *cmdstr;
|
||||||
PyObject *cmdbytes;
|
PyObject *cmdbytes;
|
||||||
|
PyGILState_STATE pygilstate;
|
||||||
|
|
||||||
#if defined(MACOS) && !defined(MACOS_X_UNIX)
|
#if defined(MACOS) && !defined(MACOS_X_UNIX)
|
||||||
GetPort(&oldPort);
|
GetPort(&oldPort);
|
||||||
|
@@ -728,6 +728,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
956,
|
||||||
/**/
|
/**/
|
||||||
955,
|
955,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user