diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2018-12-23 07:12:59 -0500 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-12-23 13:12:59 +0100 |
commit | e9685d9f70f26daa6a252baf8f5a2d411cf4b38f (patch) | |
tree | de7597f126dc445e758afa46c5073baaf73538b2 | |
parent | d2352b7b51c9ec039426493ad02840cc9c8e2c2e (diff) | |
download | rneovim-e9685d9f70f26daa6a252baf8f5a2d411cf4b38f.tar.gz rneovim-e9685d9f70f26daa6a252baf8f5a2d411cf4b38f.tar.bz2 rneovim-e9685d9f70f26daa6a252baf8f5a2d411cf4b38f.zip |
vim-patch:8.1.0627: Python cannot handle function name of script-local function (#9392)
Problem: Python cannot handle function name of script-local function.
Solution: Use <SNR> instead of the special byte code. (Ozaki Kiichi, closes
vim/vim#3681)
https://github.com/vim/vim/commit/9123c0b31a283f460ed2b6af95080120cf528118
-rw-r--r-- | src/nvim/testdir/test_python2.vim | 27 | ||||
-rw-r--r-- | src/nvim/testdir/test_python3.vim | 27 |
2 files changed, 54 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_python2.vim b/src/nvim/testdir/test_python2.vim index 63c38cd5d1..5ba9fd68cf 100644 --- a/src/nvim/testdir/test_python2.vim +++ b/src/nvim/testdir/test_python2.vim @@ -25,3 +25,30 @@ func Test_pydo() bwipe! endif endfunc + +func Test_vim_function() + " Check creating vim.Function object + py import vim + + func s:foo() + return matchstr(expand('<sfile>'), '<SNR>\zs\d\+_foo$') + endfunc + let name = '<SNR>' . s:foo() + + try + py f = vim.bindeval('function("s:foo")') + call assert_equal(name, pyeval('f.name')) + catch + call assert_false(v:exception) + endtry + + try + py f = vim.Function('\x80\xfdR' + vim.eval('s:foo()')) + call assert_equal(name, pyeval('f.name')) + catch + call assert_false(v:exception) + endtry + + py del f + delfunc s:foo +endfunc diff --git a/src/nvim/testdir/test_python3.vim b/src/nvim/testdir/test_python3.vim index f5b2c89853..2e3fc93674 100644 --- a/src/nvim/testdir/test_python3.vim +++ b/src/nvim/testdir/test_python3.vim @@ -25,3 +25,30 @@ func Test_py3do() bwipe! endif endfunc + +func Test_vim_function() + " Check creating vim.Function object + py3 import vim + + func s:foo() + return matchstr(expand('<sfile>'), '<SNR>\zs\d\+_foo$') + endfunc + let name = '<SNR>' . s:foo() + + try + py3 f = vim.bindeval('function("s:foo")') + call assert_equal(name, py3eval('f.name')) + catch + call assert_false(v:exception) + endtry + + try + py3 f = vim.Function(b'\x80\xfdR' + vim.eval('s:foo()').encode()) + call assert_equal(name, py3eval('f.name')) + catch + call assert_false(v:exception) + endtry + + py3 del f + delfunc s:foo +endfunc |