0
0
mirror of https://github.com/vim/vim.git synced 2025-10-02 05:04:20 -04:00

patch 8.1.0627: Python cannot handle function name of script-local function

Problem:    Python cannot handle function name of script-local function.
Solution:   Use <SNR> instead of the special byte code. (Ozaki Kiichi, closes
            #3681)
This commit is contained in:
Bram Moolenaar
2018-12-22 18:59:06 +01:00
parent 4814ccbdf0
commit 9123c0b31a
4 changed files with 81 additions and 5 deletions

View File

@@ -36,3 +36,30 @@ func Test_set_cursor()
normal j
call assert_equal([2, 6], [line('.'), col('.')])
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