lkundrak / rpms / vim

Forked from rpms/vim 4 years ago
Clone
ec835a4
To: vim_dev@googlegroups.com
ec835a4
Subject: Patch 7.4.380
ec835a4
Fcc: outbox
ec835a4
From: Bram Moolenaar <Bram@moolenaar.net>
ec835a4
Mime-Version: 1.0
ec835a4
Content-Type: text/plain; charset=UTF-8
ec835a4
Content-Transfer-Encoding: 8bit
ec835a4
------------
ec835a4
ec835a4
Patch 7.4.380
ec835a4
Problem:    Loading python may cause Vim to exit.
ec835a4
Solution:   Avoid loading the "site" module. (Taro Muraoka)
ec835a4
Files:	    src/if_python.c
ec835a4
ec835a4
ec835a4
*** ../vim-7.4.379/src/if_python.c	2014-03-30 16:11:37.176530823 +0200
ec835a4
--- src/if_python.c	2014-07-23 16:46:42.863880615 +0200
ec835a4
***************
ec835a4
*** 295,300 ****
ec835a4
--- 295,303 ----
ec835a4
  #  define PyCObject_FromVoidPtr dll_PyCObject_FromVoidPtr
ec835a4
  #  define PyCObject_AsVoidPtr dll_PyCObject_AsVoidPtr
ec835a4
  # endif
ec835a4
+ # if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
ec835a4
+ #  define Py_NoSiteFlag (*dll_Py_NoSiteFlag)
ec835a4
+ # endif
ec835a4
  
ec835a4
  /*
ec835a4
   * Pointers for dynamic link
ec835a4
***************
ec835a4
*** 440,445 ****
ec835a4
--- 443,451 ----
ec835a4
  static PyObject* (*dll_PyCObject_FromVoidPtr)(void *cobj, void (*destr)(void *));
ec835a4
  static void* (*dll_PyCObject_AsVoidPtr)(PyObject *);
ec835a4
  # endif
ec835a4
+ # if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
ec835a4
+ static int* dll_Py_NoSiteFlag;
ec835a4
+ # endif
ec835a4
  
ec835a4
  static HINSTANCE hinstPython = 0; /* Instance of python.dll */
ec835a4
  
ec835a4
***************
ec835a4
*** 633,638 ****
ec835a4
--- 639,647 ----
ec835a4
      {"PyCObject_FromVoidPtr", (PYTHON_PROC*)&dll_PyCObject_FromVoidPtr},
ec835a4
      {"PyCObject_AsVoidPtr", (PYTHON_PROC*)&dll_PyCObject_AsVoidPtr},
ec835a4
  # endif
ec835a4
+ # if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
ec835a4
+     {"Py_NoSiteFlag", (PYTHON_PROC*)&dll_Py_NoSiteFlag},
ec835a4
+ # endif
ec835a4
      {"", NULL},
ec835a4
  };
ec835a4
  
ec835a4
***************
ec835a4
*** 901,906 ****
ec835a4
--- 910,919 ----
ec835a4
  {
ec835a4
      if (!initialised)
ec835a4
      {
ec835a4
+ #if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
ec835a4
+ 	PyObject *site;
ec835a4
+ #endif
ec835a4
+ 
ec835a4
  #ifdef DYNAMIC_PYTHON
ec835a4
  	if (!python_enabled(TRUE))
ec835a4
  	{
ec835a4
***************
ec835a4
*** 915,925 ****
ec835a4
--- 928,956 ----
ec835a4
  
ec835a4
  	init_structs();
ec835a4
  
ec835a4
+ #if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
ec835a4
+ 	/* Disable implicit 'import site', because it may cause Vim to exit
ec835a4
+ 	 * when it can't be found. */
ec835a4
+ 	Py_NoSiteFlag++;
ec835a4
+ #endif
ec835a4
+ 
ec835a4
  #if !defined(MACOS) || defined(MACOS_X_UNIX)
ec835a4
  	Py_Initialize();
ec835a4
  #else
ec835a4
  	PyMac_Initialize();
ec835a4
  #endif
ec835a4
+ 
ec835a4
+ #if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
ec835a4
+ 	/* 'import site' explicitly. */
ec835a4
+ 	site = PyImport_ImportModule("site");
ec835a4
+ 	if (site == NULL)
ec835a4
+ 	{
ec835a4
+ 	    EMSG(_("E887: Sorry, this command is disabled, the Python's site module could not be loaded."));
ec835a4
+ 	    goto fail;
ec835a4
+ 	}
ec835a4
+ 	Py_DECREF(site);
ec835a4
+ #endif
ec835a4
+ 
ec835a4
  	/* Initialise threads, and below save the state using
ec835a4
  	 * PyEval_SaveThread.  Without the call to PyEval_SaveThread, thread
ec835a4
  	 * specific state (such as the system trace hook), will be lost
ec835a4
*** ../vim-7.4.379/src/version.c	2014-07-23 16:33:04.079886500 +0200
ec835a4
--- src/version.c	2014-07-23 16:43:47.939881872 +0200
ec835a4
***************
ec835a4
*** 736,737 ****
ec835a4
--- 736,739 ----
ec835a4
  {   /* Add new patch number below this line */
ec835a4
+ /**/
ec835a4
+     380,
ec835a4
  /**/
ec835a4
ec835a4
-- 
ec835a4
Looking at Perl through Lisp glasses, Perl looks atrocious.
ec835a4
ec835a4
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
ec835a4
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
ec835a4
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
ec835a4
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///