From e9685d9f70f26daa6a252baf8f5a2d411cf4b38f Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 23 Dec 2018 07:12:59 -0500 Subject: 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 instead of the special byte code. (Ozaki Kiichi, closes vim/vim#3681) https://github.com/vim/vim/commit/9123c0b31a283f460ed2b6af95080120cf528118 --- src/nvim/testdir/test_python2.vim | 27 +++++++++++++++++++++++++++ src/nvim/testdir/test_python3.vim | 27 +++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) (limited to 'src') 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(''), '\zs\d\+_foo$') + endfunc + let name = '' . 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(''), '\zs\d\+_foo$') + endfunc + let name = '' . 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 -- cgit