Skip to content

Commit 4c90861

Browse files
committed
patch 7.4.1646
Problem: Using Python vim.bindeval() on a partial doesn't work. (Nikolai Pavlov) Solution: Add VAR_PARTIAL support in Python.
1 parent c5fbe8a commit 4c90861

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

src/if_py_both.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6032,13 +6032,26 @@ ConvertToPyObject(typval_T *tv)
60326032
case VAR_FUNC:
60336033
return NEW_FUNCTION(tv->vval.v_string == NULL
60346034
? (char_u *)"" : tv->vval.v_string);
6035+
case VAR_PARTIAL:
6036+
return NEW_FUNCTION(tv->vval.v_partial == NULL
6037+
? (char_u *)"" : tv->vval.v_partial->pt_name);
60356038
case VAR_UNKNOWN:
6039+
case VAR_CHANNEL:
6040+
case VAR_JOB:
60366041
Py_INCREF(Py_None);
60376042
return Py_None;
6038-
default:
6043+
case VAR_SPECIAL:
6044+
switch (tv->vval.v_number)
6045+
{
6046+
case VVAL_FALSE: return AlwaysFalse(NULL);
6047+
case VVAL_TRUE: return AlwaysTrue(NULL);
6048+
case VVAL_NONE:
6049+
case VVAL_NULL: return AlwaysNone(NULL);
6050+
}
60396051
PyErr_SET_VIM(N_("internal error: invalid value type"));
60406052
return NULL;
60416053
}
6054+
return NULL;
60426055
}
60436056

60446057
typedef struct

src/testdir/test_partial.vim

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,3 +206,17 @@ func Test_redefine_dict_func()
206206
call assert_true(v:errmsg, v:exception)
207207
endtry
208208
endfunc
209+
210+
func Test_bind_in_python()
211+
if has('python')
212+
let g:d = {}
213+
function g:d.test2()
214+
endfunction
215+
python import vim
216+
try
217+
call assert_equal(pyeval('vim.bindeval("g:d.test2")'), g:d.test2)
218+
catch
219+
call assert_true(v:false, v:exception)
220+
endtry
221+
endif
222+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,8 @@ static char *(features[]) =
748748

749749
static int included_patches[] =
750750
{ /* Add new patch number below this line */
751+
/**/
752+
1646,
751753
/**/
752754
1645,
753755
/**/

0 commit comments

Comments
 (0)