0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

updated for version 7.4.380

Problem:    Loading python may cause Vim to exit.
Solution:   Avoid loading the "site" module. (Taro Muraoka)
This commit is contained in:
Bram Moolenaar 2014-07-23 16:57:00 +02:00
parent 158a1b0748
commit 12a28d4b29
2 changed files with 33 additions and 0 deletions

View File

@ -295,6 +295,9 @@ struct PyMethodDef { Py_ssize_t a; };
# define PyCObject_FromVoidPtr dll_PyCObject_FromVoidPtr # define PyCObject_FromVoidPtr dll_PyCObject_FromVoidPtr
# define PyCObject_AsVoidPtr dll_PyCObject_AsVoidPtr # define PyCObject_AsVoidPtr dll_PyCObject_AsVoidPtr
# endif # endif
# if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
# define Py_NoSiteFlag (*dll_Py_NoSiteFlag)
# endif
/* /*
* Pointers for dynamic link * Pointers for dynamic link
@ -440,6 +443,9 @@ static void* (*dll_PyCapsule_GetPointer)(PyObject *, char *);
static PyObject* (*dll_PyCObject_FromVoidPtr)(void *cobj, void (*destr)(void *)); static PyObject* (*dll_PyCObject_FromVoidPtr)(void *cobj, void (*destr)(void *));
static void* (*dll_PyCObject_AsVoidPtr)(PyObject *); static void* (*dll_PyCObject_AsVoidPtr)(PyObject *);
# endif # endif
# if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
static int* dll_Py_NoSiteFlag;
# endif
static HINSTANCE hinstPython = 0; /* Instance of python.dll */ static HINSTANCE hinstPython = 0; /* Instance of python.dll */
@ -632,6 +638,9 @@ static struct
# else # else
{"PyCObject_FromVoidPtr", (PYTHON_PROC*)&dll_PyCObject_FromVoidPtr}, {"PyCObject_FromVoidPtr", (PYTHON_PROC*)&dll_PyCObject_FromVoidPtr},
{"PyCObject_AsVoidPtr", (PYTHON_PROC*)&dll_PyCObject_AsVoidPtr}, {"PyCObject_AsVoidPtr", (PYTHON_PROC*)&dll_PyCObject_AsVoidPtr},
# endif
# if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
{"Py_NoSiteFlag", (PYTHON_PROC*)&dll_Py_NoSiteFlag},
# endif # endif
{"", NULL}, {"", NULL},
}; };
@ -901,6 +910,10 @@ Python_Init(void)
{ {
if (!initialised) if (!initialised)
{ {
#if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
PyObject *site;
#endif
#ifdef DYNAMIC_PYTHON #ifdef DYNAMIC_PYTHON
if (!python_enabled(TRUE)) if (!python_enabled(TRUE))
{ {
@ -915,11 +928,29 @@ Python_Init(void)
init_structs(); init_structs();
#if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
/* Disable implicit 'import site', because it may cause Vim to exit
* when it can't be found. */
Py_NoSiteFlag++;
#endif
#if !defined(MACOS) || defined(MACOS_X_UNIX) #if !defined(MACOS) || defined(MACOS_X_UNIX)
Py_Initialize(); Py_Initialize();
#else #else
PyMac_Initialize(); PyMac_Initialize();
#endif #endif
#if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
/* 'import site' explicitly. */
site = PyImport_ImportModule("site");
if (site == NULL)
{
EMSG(_("E887: Sorry, this command is disabled, the Python's site module could not be loaded."));
goto fail;
}
Py_DECREF(site);
#endif
/* Initialise threads, and below save the state using /* Initialise threads, and below save the state using
* PyEval_SaveThread. Without the call to PyEval_SaveThread, thread * PyEval_SaveThread. Without the call to PyEval_SaveThread, thread
* specific state (such as the system trace hook), will be lost * specific state (such as the system trace hook), will be lost

View File

@ -734,6 +734,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 */
/**/
380,
/**/ /**/
379, 379,
/**/ /**/