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)
9123c0b31a
This commit is contained in:
Jan Edmund Lazo
2018-12-23 07:12:59 -05:00
committed by Justin M. Keyes
parent d2352b7b51
commit e9685d9f70
2 changed files with 54 additions and 0 deletions

View File

@@ -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

View File

@@ -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