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