Vim python interface bug.
Between any consecutive python code invocations, for example:
:py def x(): print "hello World"
and:
:py x()
State, specific to the (main) python thread is discarded. For example, any
attempt to use sys.settrace() fails to provide the expected results.
The attached patch fixes this for at least one case.
FYI. I was trying to test vim-python extension code and obtain code coverage
statistics using Ned Batchelder's covergae.py.
I have just built this into my everyday Vim instance. I will update this post
to indicate any problems or (lack thereof).
--
Paul
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff -r b042d04009d4 src/if_python.c
--- a/src/if_python.c Sat Oct 06 19:10:36 2012 +0200
+++ b/src/if_python.c Mon Oct 08 22:56:01 2012 +0100
@@ -740,9 +740,13 @@
#else
PyMac_Initialize();
#endif
- /* initialise threads */
+ /* Initialise threads, and save the state using PyGILState_Ensure.
+ * Without the call to PyGILState_Ensure, thread specific state (such
+ * as the system trace hook), will be lost between invocations of
+ * Python code.
+ */
PyEval_InitThreads();
-
+ pygilstate = PyGILState_Ensure();
#ifdef DYNAMIC_PYTHON
get_exceptions();
#endif