diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-03-24 21:58:12 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-03-24 21:58:12 +0100 |
commit | 4c90861e9f864eab94f043c432acff508396ed62 (patch) | |
tree | 3dd833ecd38ad0b11bacb07d250469e439c2249f | |
parent | c5fbe8af4cd80789f831b78aa44ff0b238138769 (diff) | |
download | vim-git-4c90861e9f864eab94f043c432acff508396ed62.tar.gz |
patch 7.4.1646v7.4.1646
Problem: Using Python vim.bindeval() on a partial doesn't work. (Nikolai
Pavlov)
Solution: Add VAR_PARTIAL support in Python.
-rw-r--r-- | src/if_py_both.h | 15 | ||||
-rw-r--r-- | src/testdir/test_partial.vim | 14 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 30 insertions, 1 deletions
diff --git a/src/if_py_both.h b/src/if_py_both.h index 3a80cb4ef..ee882600f 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -6032,13 +6032,26 @@ ConvertToPyObject(typval_T *tv) case VAR_FUNC: return NEW_FUNCTION(tv->vval.v_string == NULL ? (char_u *)"" : tv->vval.v_string); + case VAR_PARTIAL: + return NEW_FUNCTION(tv->vval.v_partial == NULL + ? (char_u *)"" : tv->vval.v_partial->pt_name); case VAR_UNKNOWN: + case VAR_CHANNEL: + case VAR_JOB: Py_INCREF(Py_None); return Py_None; - default: + case VAR_SPECIAL: + switch (tv->vval.v_number) + { + case VVAL_FALSE: return AlwaysFalse(NULL); + case VVAL_TRUE: return AlwaysTrue(NULL); + case VVAL_NONE: + case VVAL_NULL: return AlwaysNone(NULL); + } PyErr_SET_VIM(N_("internal error: invalid value type")); return NULL; } + return NULL; } typedef struct diff --git a/src/testdir/test_partial.vim b/src/testdir/test_partial.vim index 1fe67eabc..08958de83 100644 --- a/src/testdir/test_partial.vim +++ b/src/testdir/test_partial.vim @@ -206,3 +206,17 @@ func Test_redefine_dict_func() call assert_true(v:errmsg, v:exception) endtry endfunc + +func Test_bind_in_python() + if has('python') + let g:d = {} + function g:d.test2() + endfunction + python import vim + try + call assert_equal(pyeval('vim.bindeval("g:d.test2")'), g:d.test2) + catch + call assert_true(v:false, v:exception) + endtry + endif +endfunc diff --git a/src/version.c b/src/version.c index dd9b5c285..4ab8eed71 100644 --- a/src/version.c +++ b/src/version.c @@ -749,6 +749,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1646, +/**/ 1645, /**/ 1644, |