summaryrefslogtreecommitdiffstats
path: root/patches/source/vim/patches/7.4.380
blob: 8c93e07725e3b89f025306bb1340ac11b4d68511 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
To: vim_dev@googlegroups.com
Subject: Patch 7.4.380
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.4.380
Problem:    Loading python may cause Vim to exit.
Solution:   Avoid loading the "site" module. (Taro Muraoka)
Files:	    src/if_python.c


*** ../vim-7.4.379/src/if_python.c	2014-03-30 16:11:37.176530823 +0200
--- src/if_python.c	2014-07-23 16:46:42.863880615 +0200
***************
*** 295,300 ****
--- 295,303 ----
  #  define PyCObject_FromVoidPtr dll_PyCObject_FromVoidPtr
  #  define PyCObject_AsVoidPtr dll_PyCObject_AsVoidPtr
  # endif
+ # if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
+ #  define Py_NoSiteFlag (*dll_Py_NoSiteFlag)
+ # endif
  
  /*
   * Pointers for dynamic link
***************
*** 440,445 ****
--- 443,451 ----
  static PyObject* (*dll_PyCObject_FromVoidPtr)(void *cobj, void (*destr)(void *));
  static void* (*dll_PyCObject_AsVoidPtr)(PyObject *);
  # endif
+ # if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
+ static int* dll_Py_NoSiteFlag;
+ # endif
  
  static HINSTANCE hinstPython = 0; /* Instance of python.dll */
  
***************
*** 633,638 ****
--- 639,647 ----
      {"PyCObject_FromVoidPtr", (PYTHON_PROC*)&dll_PyCObject_FromVoidPtr},
      {"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
      {"", NULL},
  };
  
***************
*** 901,906 ****
--- 910,919 ----
  {
      if (!initialised)
      {
+ #if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
+ 	PyObject *site;
+ #endif
+ 
  #ifdef DYNAMIC_PYTHON
  	if (!python_enabled(TRUE))
  	{
***************
*** 915,925 ****
--- 928,956 ----
  
  	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)
  	Py_Initialize();
  #else
  	PyMac_Initialize();
  #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
  	 * PyEval_SaveThread.  Without the call to PyEval_SaveThread, thread
  	 * specific state (such as the system trace hook), will be lost
*** ../vim-7.4.379/src/version.c	2014-07-23 16:33:04.079886500 +0200
--- src/version.c	2014-07-23 16:43:47.939881872 +0200
***************
*** 736,737 ****
--- 736,739 ----
  {   /* Add new patch number below this line */
+ /**/
+     380,
  /**/

-- 
Looking at Perl through Lisp glasses, Perl looks atrocious.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///