mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
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:

committed by
Justin M. Keyes

parent
d2352b7b51
commit
e9685d9f70
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user