mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 9.1.0844: if_python: no way to pass local vars to python
Problem: if_python: no way to pass local vars to python Solution: Add locals argument to py3eval(), pyeval() and pyxeval() (Ben Jackson) fixes: #8573 closes: #10594 Signed-off-by: Ben Jackson <puremourning@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
fd1a838d36
commit
ea19e7856b
@@ -1436,7 +1436,11 @@ fail:
|
||||
* External interface
|
||||
*/
|
||||
static void
|
||||
DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg)
|
||||
DoPyCommand(const char *cmd,
|
||||
dict_T* locals,
|
||||
rangeinitializer init_range,
|
||||
runner run,
|
||||
void *arg)
|
||||
{
|
||||
#if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
|
||||
char *saved_locale;
|
||||
@@ -1477,7 +1481,7 @@ DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg)
|
||||
cmdbytes = PyUnicode_AsEncodedString(cmdstr, "utf-8", ERRORS_ENCODE_ARG);
|
||||
Py_XDECREF(cmdstr);
|
||||
|
||||
run(PyBytes_AsString(cmdbytes), arg, &pygilstate);
|
||||
run(PyBytes_AsString(cmdbytes), locals, arg, &pygilstate);
|
||||
Py_XDECREF(cmdbytes);
|
||||
|
||||
PyGILState_Release(pygilstate);
|
||||
@@ -1512,6 +1516,7 @@ ex_py3(exarg_T *eap)
|
||||
p_pyx = 3;
|
||||
|
||||
DoPyCommand(script == NULL ? (char *) eap->arg : (char *) script,
|
||||
NULL,
|
||||
init_range_cmd,
|
||||
(runner) run_cmd,
|
||||
(void *) eap);
|
||||
@@ -1578,6 +1583,7 @@ ex_py3file(exarg_T *eap)
|
||||
|
||||
// Execute the file
|
||||
DoPyCommand(buffer,
|
||||
NULL,
|
||||
init_range_cmd,
|
||||
(runner) run_cmd,
|
||||
(void *) eap);
|
||||
@@ -1590,6 +1596,7 @@ ex_py3do(exarg_T *eap)
|
||||
p_pyx = 3;
|
||||
|
||||
DoPyCommand((char *)eap->arg,
|
||||
NULL,
|
||||
init_range_cmd,
|
||||
(runner)run_do,
|
||||
(void *)eap);
|
||||
@@ -2137,9 +2144,10 @@ LineToString(const char *str)
|
||||
}
|
||||
|
||||
void
|
||||
do_py3eval(char_u *str, typval_T *rettv)
|
||||
do_py3eval(char_u *str, dict_T *locals, typval_T *rettv)
|
||||
{
|
||||
DoPyCommand((char *) str,
|
||||
locals,
|
||||
init_range_eval,
|
||||
(runner) run_eval,
|
||||
(void *) rettv);
|
||||
|
Reference in New Issue
Block a user