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)
diff --git a/src/testdir/test_python2.vim b/src/testdir/test_python2.vim
index c438ba0..d79400d 100644
--- a/src/testdir/test_python2.vim
+++ b/src/testdir/test_python2.vim
@@ -36,3 +36,30 @@
normal j
call assert_equal([2, 6], [line('.'), col('.')])
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