Karsten Hopp dc13e8
To: vim_dev@googlegroups.com
Karsten Hopp dc13e8
Subject: Patch 7.3.956
Karsten Hopp dc13e8
Fcc: outbox
Karsten Hopp dc13e8
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp dc13e8
Mime-Version: 1.0
Karsten Hopp dc13e8
Content-Type: text/plain; charset=UTF-8
Karsten Hopp dc13e8
Content-Transfer-Encoding: 8bit
Karsten Hopp dc13e8
------------
Karsten Hopp dc13e8
Karsten Hopp dc13e8
Patch 7.3.956
Karsten Hopp dc13e8
Problem:    Python vim.bindeval() causes SIGABRT.
Karsten Hopp dc13e8
Solution:   Make pygilstate a local variable. (Yukihiro Nakadaira)
Karsten Hopp dc13e8
Files:	    src/if_py_both.h, src/if_python.c, src/if_python3.c
Karsten Hopp dc13e8
Karsten Hopp dc13e8
Karsten Hopp dc13e8
*** ../vim-7.3.955/src/if_py_both.h	2013-05-15 16:11:46.000000000 +0200
Karsten Hopp dc13e8
--- src/if_py_both.h	2013-05-15 17:37:48.000000000 +0200
Karsten Hopp dc13e8
***************
Karsten Hopp dc13e8
*** 1298,1304 ****
Karsten Hopp dc13e8
--- 1298,1311 ----
Karsten Hopp dc13e8
  	}
Karsten Hopp dc13e8
      }
Karsten Hopp dc13e8
  
Karsten Hopp dc13e8
+     Py_BEGIN_ALLOW_THREADS
Karsten Hopp dc13e8
+     Python_Lock_Vim();
Karsten Hopp dc13e8
+ 
Karsten Hopp dc13e8
      error = func_call(name, &args, selfdict, &rettv);
Karsten Hopp dc13e8
+ 
Karsten Hopp dc13e8
+     Python_Release_Vim();
Karsten Hopp dc13e8
+     Py_END_ALLOW_THREADS
Karsten Hopp dc13e8
+ 
Karsten Hopp dc13e8
      if (error != OK)
Karsten Hopp dc13e8
      {
Karsten Hopp dc13e8
  	result = NULL;
Karsten Hopp dc13e8
*** ../vim-7.3.955/src/if_python.c	2013-05-15 16:04:34.000000000 +0200
Karsten Hopp dc13e8
--- src/if_python.c	2013-05-15 17:37:48.000000000 +0200
Karsten Hopp dc13e8
***************
Karsten Hopp dc13e8
*** 676,686 ****
Karsten Hopp dc13e8
  typedef PyObject PyThreadState;
Karsten Hopp dc13e8
  #endif
Karsten Hopp dc13e8
  
Karsten Hopp dc13e8
! #ifdef PY_CAN_RECURSE
Karsten Hopp dc13e8
! static PyGILState_STATE pygilstate = PyGILState_UNLOCKED;
Karsten Hopp dc13e8
! #else
Karsten Hopp dc13e8
  static PyThreadState *saved_python_thread = NULL;
Karsten Hopp dc13e8
- #endif
Karsten Hopp dc13e8
  
Karsten Hopp dc13e8
  /*
Karsten Hopp dc13e8
   * Suspend a thread of the Python interpreter, other threads are allowed to
Karsten Hopp dc13e8
--- 676,683 ----
Karsten Hopp dc13e8
  typedef PyObject PyThreadState;
Karsten Hopp dc13e8
  #endif
Karsten Hopp dc13e8
  
Karsten Hopp dc13e8
! #ifndef PY_CAN_RECURSE
Karsten Hopp dc13e8
  static PyThreadState *saved_python_thread = NULL;
Karsten Hopp dc13e8
  
Karsten Hopp dc13e8
  /*
Karsten Hopp dc13e8
   * Suspend a thread of the Python interpreter, other threads are allowed to
Karsten Hopp dc13e8
***************
Karsten Hopp dc13e8
*** 689,699 ****
Karsten Hopp dc13e8
      static void
Karsten Hopp dc13e8
  Python_SaveThread(void)
Karsten Hopp dc13e8
  {
Karsten Hopp dc13e8
- #ifdef PY_CAN_RECURSE
Karsten Hopp dc13e8
-     PyGILState_Release(pygilstate);
Karsten Hopp dc13e8
- #else
Karsten Hopp dc13e8
      saved_python_thread = PyEval_SaveThread();
Karsten Hopp dc13e8
- #endif
Karsten Hopp dc13e8
  }
Karsten Hopp dc13e8
  
Karsten Hopp dc13e8
  /*
Karsten Hopp dc13e8
--- 686,692 ----
Karsten Hopp dc13e8
***************
Karsten Hopp dc13e8
*** 703,715 ****
Karsten Hopp dc13e8
      static void
Karsten Hopp dc13e8
  Python_RestoreThread(void)
Karsten Hopp dc13e8
  {
Karsten Hopp dc13e8
- #ifdef PY_CAN_RECURSE
Karsten Hopp dc13e8
-     pygilstate = PyGILState_Ensure();
Karsten Hopp dc13e8
- #else
Karsten Hopp dc13e8
      PyEval_RestoreThread(saved_python_thread);
Karsten Hopp dc13e8
      saved_python_thread = NULL;
Karsten Hopp dc13e8
- #endif
Karsten Hopp dc13e8
  }
Karsten Hopp dc13e8
  
Karsten Hopp dc13e8
      void
Karsten Hopp dc13e8
  python_end()
Karsten Hopp dc13e8
--- 696,705 ----
Karsten Hopp dc13e8
      static void
Karsten Hopp dc13e8
  Python_RestoreThread(void)
Karsten Hopp dc13e8
  {
Karsten Hopp dc13e8
      PyEval_RestoreThread(saved_python_thread);
Karsten Hopp dc13e8
      saved_python_thread = NULL;
Karsten Hopp dc13e8
  }
Karsten Hopp dc13e8
+ #endif
Karsten Hopp dc13e8
  
Karsten Hopp dc13e8
      void
Karsten Hopp dc13e8
  python_end()
Karsten Hopp dc13e8
***************
Karsten Hopp dc13e8
*** 725,738 ****
Karsten Hopp dc13e8
--- 715,736 ----
Karsten Hopp dc13e8
  #ifdef DYNAMIC_PYTHON
Karsten Hopp dc13e8
      if (hinstPython && Py_IsInitialized())
Karsten Hopp dc13e8
      {
Karsten Hopp dc13e8
+ # ifdef PY_CAN_RECURSE
Karsten Hopp dc13e8
+ 	PyGILState_Ensure();
Karsten Hopp dc13e8
+ # else
Karsten Hopp dc13e8
  	Python_RestoreThread();	    /* enter python */
Karsten Hopp dc13e8
+ # endif
Karsten Hopp dc13e8
  	Py_Finalize();
Karsten Hopp dc13e8
      }
Karsten Hopp dc13e8
      end_dynamic_python();
Karsten Hopp dc13e8
  #else
Karsten Hopp dc13e8
      if (Py_IsInitialized())
Karsten Hopp dc13e8
      {
Karsten Hopp dc13e8
+ # ifdef PY_CAN_RECURSE
Karsten Hopp dc13e8
+ 	PyGILState_Ensure();
Karsten Hopp dc13e8
+ # else
Karsten Hopp dc13e8
  	Python_RestoreThread();	    /* enter python */
Karsten Hopp dc13e8
+ # endif
Karsten Hopp dc13e8
  	Py_Finalize();
Karsten Hopp dc13e8
      }
Karsten Hopp dc13e8
  #endif
Karsten Hopp dc13e8
***************
Karsten Hopp dc13e8
*** 837,842 ****
Karsten Hopp dc13e8
--- 835,843 ----
Karsten Hopp dc13e8
  #if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
Karsten Hopp dc13e8
      char		*saved_locale;
Karsten Hopp dc13e8
  #endif
Karsten Hopp dc13e8
+ #ifdef PY_CAN_RECURSE
Karsten Hopp dc13e8
+     PyGILState_STATE	pygilstate;
Karsten Hopp dc13e8
+ #endif
Karsten Hopp dc13e8
  
Karsten Hopp dc13e8
  #ifndef PY_CAN_RECURSE
Karsten Hopp dc13e8
      if (recursive)
Karsten Hopp dc13e8
***************
Karsten Hopp dc13e8
*** 881,887 ****
Karsten Hopp dc13e8
--- 882,892 ----
Karsten Hopp dc13e8
      }
Karsten Hopp dc13e8
  #endif
Karsten Hopp dc13e8
  
Karsten Hopp dc13e8
+ #ifdef PY_CAN_RECURSE
Karsten Hopp dc13e8
+     pygilstate = PyGILState_Ensure();
Karsten Hopp dc13e8
+ #else
Karsten Hopp dc13e8
      Python_RestoreThread();	    /* enter python */
Karsten Hopp dc13e8
+ #endif
Karsten Hopp dc13e8
  
Karsten Hopp dc13e8
      if (rettv == NULL)
Karsten Hopp dc13e8
  	PyRun_SimpleString((char *)(cmd));
Karsten Hopp dc13e8
***************
Karsten Hopp dc13e8
*** 905,911 ****
Karsten Hopp dc13e8
--- 910,920 ----
Karsten Hopp dc13e8
  	PyErr_Clear();
Karsten Hopp dc13e8
      }
Karsten Hopp dc13e8
  
Karsten Hopp dc13e8
+ #ifdef PY_CAN_RECURSE
Karsten Hopp dc13e8
+     PyGILState_Release(pygilstate);
Karsten Hopp dc13e8
+ #else
Karsten Hopp dc13e8
      Python_SaveThread();	    /* leave python */
Karsten Hopp dc13e8
+ #endif
Karsten Hopp dc13e8
  
Karsten Hopp dc13e8
  #if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
Karsten Hopp dc13e8
      if (saved_locale != NULL)
Karsten Hopp dc13e8
*** ../vim-7.3.955/src/if_python3.c	2013-05-15 16:04:34.000000000 +0200
Karsten Hopp dc13e8
--- src/if_python3.c	2013-05-15 17:37:48.000000000 +0200
Karsten Hopp dc13e8
***************
Karsten Hopp dc13e8
*** 699,706 ****
Karsten Hopp dc13e8
   * 1. Python interpreter main program.
Karsten Hopp dc13e8
   */
Karsten Hopp dc13e8
  
Karsten Hopp dc13e8
- static PyGILState_STATE pygilstate = PyGILState_UNLOCKED;
Karsten Hopp dc13e8
- 
Karsten Hopp dc13e8
      void
Karsten Hopp dc13e8
  python3_end()
Karsten Hopp dc13e8
  {
Karsten Hopp dc13e8
--- 699,704 ----
Karsten Hopp dc13e8
***************
Karsten Hopp dc13e8
*** 718,724 ****
Karsten Hopp dc13e8
      if (Py_IsInitialized())
Karsten Hopp dc13e8
      {
Karsten Hopp dc13e8
  	// acquire lock before finalizing
Karsten Hopp dc13e8
! 	pygilstate = PyGILState_Ensure();
Karsten Hopp dc13e8
  
Karsten Hopp dc13e8
  	Py_Finalize();
Karsten Hopp dc13e8
      }
Karsten Hopp dc13e8
--- 716,722 ----
Karsten Hopp dc13e8
      if (Py_IsInitialized())
Karsten Hopp dc13e8
      {
Karsten Hopp dc13e8
  	// acquire lock before finalizing
Karsten Hopp dc13e8
! 	PyGILState_Ensure();
Karsten Hopp dc13e8
  
Karsten Hopp dc13e8
  	Py_Finalize();
Karsten Hopp dc13e8
      }
Karsten Hopp dc13e8
***************
Karsten Hopp dc13e8
*** 826,831 ****
Karsten Hopp dc13e8
--- 824,830 ----
Karsten Hopp dc13e8
  #endif
Karsten Hopp dc13e8
      PyObject		*cmdstr;
Karsten Hopp dc13e8
      PyObject		*cmdbytes;
Karsten Hopp dc13e8
+     PyGILState_STATE	pygilstate;
Karsten Hopp dc13e8
  
Karsten Hopp dc13e8
  #if defined(MACOS) && !defined(MACOS_X_UNIX)
Karsten Hopp dc13e8
      GetPort(&oldPort);
Karsten Hopp dc13e8
*** ../vim-7.3.955/src/version.c	2013-05-15 16:27:33.000000000 +0200
Karsten Hopp dc13e8
--- src/version.c	2013-05-15 17:48:15.000000000 +0200
Karsten Hopp dc13e8
***************
Karsten Hopp dc13e8
*** 730,731 ****
Karsten Hopp dc13e8
--- 730,733 ----
Karsten Hopp dc13e8
  {   /* Add new patch number below this line */
Karsten Hopp dc13e8
+ /**/
Karsten Hopp dc13e8
+     956,
Karsten Hopp dc13e8
  /**/
Karsten Hopp dc13e8
Karsten Hopp dc13e8
-- 
Karsten Hopp dc13e8
GUEST:        He's killed the best man!
Karsten Hopp dc13e8
SECOND GUEST: (holding a limp WOMAN) He's killed my auntie.
Karsten Hopp dc13e8
FATHER:       No, please!  This is supposed to be a happy occasion!  Let's
Karsten Hopp dc13e8
              not bicker and argue about who killed who ...
Karsten Hopp dc13e8
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
Karsten Hopp dc13e8
Karsten Hopp dc13e8
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp dc13e8
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp dc13e8
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp dc13e8
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///