home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.4 / 7.4.380 < prev    next >
Encoding:
Internet Message Format  |  2014-07-22  |  3.2 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.4.380
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.4.380
  11. Problem:    Loading python may cause Vim to exit.
  12. Solution:   Avoid loading the "site" module. (Taro Muraoka)
  13. Files:        src/if_python.c
  14.  
  15.  
  16. *** ../vim-7.4.379/src/if_python.c    2014-03-30 16:11:37.176530823 +0200
  17. --- src/if_python.c    2014-07-23 16:46:42.863880615 +0200
  18. ***************
  19. *** 295,300 ****
  20. --- 295,303 ----
  21.   #  define PyCObject_FromVoidPtr dll_PyCObject_FromVoidPtr
  22.   #  define PyCObject_AsVoidPtr dll_PyCObject_AsVoidPtr
  23.   # endif
  24. + # if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
  25. + #  define Py_NoSiteFlag (*dll_Py_NoSiteFlag)
  26. + # endif
  27.   
  28.   /*
  29.    * Pointers for dynamic link
  30. ***************
  31. *** 440,445 ****
  32. --- 443,451 ----
  33.   static PyObject* (*dll_PyCObject_FromVoidPtr)(void *cobj, void (*destr)(void *));
  34.   static void* (*dll_PyCObject_AsVoidPtr)(PyObject *);
  35.   # endif
  36. + # if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
  37. + static int* dll_Py_NoSiteFlag;
  38. + # endif
  39.   
  40.   static HINSTANCE hinstPython = 0; /* Instance of python.dll */
  41.   
  42. ***************
  43. *** 633,638 ****
  44. --- 639,647 ----
  45.       {"PyCObject_FromVoidPtr", (PYTHON_PROC*)&dll_PyCObject_FromVoidPtr},
  46.       {"PyCObject_AsVoidPtr", (PYTHON_PROC*)&dll_PyCObject_AsVoidPtr},
  47.   # endif
  48. + # if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
  49. +     {"Py_NoSiteFlag", (PYTHON_PROC*)&dll_Py_NoSiteFlag},
  50. + # endif
  51.       {"", NULL},
  52.   };
  53.   
  54. ***************
  55. *** 901,906 ****
  56. --- 910,919 ----
  57.   {
  58.       if (!initialised)
  59.       {
  60. + #if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
  61. +     PyObject *site;
  62. + #endif
  63.   #ifdef DYNAMIC_PYTHON
  64.       if (!python_enabled(TRUE))
  65.       {
  66. ***************
  67. *** 915,925 ****
  68. --- 928,956 ----
  69.   
  70.       init_structs();
  71.   
  72. + #if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
  73. +     /* Disable implicit 'import site', because it may cause Vim to exit
  74. +      * when it can't be found. */
  75. +     Py_NoSiteFlag++;
  76. + #endif
  77.   #if !defined(MACOS) || defined(MACOS_X_UNIX)
  78.       Py_Initialize();
  79.   #else
  80.       PyMac_Initialize();
  81.   #endif
  82. + #if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
  83. +     /* 'import site' explicitly. */
  84. +     site = PyImport_ImportModule("site");
  85. +     if (site == NULL)
  86. +     {
  87. +         EMSG(_("E887: Sorry, this command is disabled, the Python's site module could not be loaded."));
  88. +         goto fail;
  89. +     }
  90. +     Py_DECREF(site);
  91. + #endif
  92.       /* Initialise threads, and below save the state using
  93.        * PyEval_SaveThread.  Without the call to PyEval_SaveThread, thread
  94.        * specific state (such as the system trace hook), will be lost
  95. *** ../vim-7.4.379/src/version.c    2014-07-23 16:33:04.079886500 +0200
  96. --- src/version.c    2014-07-23 16:43:47.939881872 +0200
  97. ***************
  98. *** 736,737 ****
  99. --- 736,739 ----
  100.   {   /* Add new patch number below this line */
  101. + /**/
  102. +     380,
  103.   /**/
  104.  
  105. -- 
  106. Looking at Perl through Lisp glasses, Perl looks atrocious.
  107.  
  108.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  109. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  110. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  111.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  112.