diff --git a/runtime/autoload/python3complete.vim b/runtime/autoload/python3complete.vim index 1f074305f1..86617e0aa7 100644 --- a/runtime/autoload/python3complete.vim +++ b/runtime/autoload/python3complete.vim @@ -135,6 +135,9 @@ class Completer(object): self.parser = PyParser() def evalsource(self,text,line=0): + # vim is imported locally in vimpy3complete(); re-import here so the + # vim.eval() below works (otherwise NameError, silently caught). + import vim sc = self.parser.parse(text,line) try: allow_imports = int( vim.eval("get(g:, 'pythoncomplete_allow_import', 0)")) diff --git a/runtime/autoload/pythoncomplete.vim b/runtime/autoload/pythoncomplete.vim index e9fd9dc490..eb87bd6c0f 100644 --- a/runtime/autoload/pythoncomplete.vim +++ b/runtime/autoload/pythoncomplete.vim @@ -149,6 +149,9 @@ class Completer(object): self.parser = PyParser() def evalsource(self,text,line=0): + # vim is imported locally in vimcomplete(); re-import here so the + # vim.eval() below works (otherwise NameError, silently caught). + import vim sc = self.parser.parse(text,line) try: allow_imports = int( vim.eval("get(g:, 'pythoncomplete_allow_import', 0)")) diff --git a/test/old/testdir/test_popup.vim b/test/old/testdir/test_popup.vim index 07e3d8540b..633b45a506 100644 --- a/test/old/testdir/test_popup.vim +++ b/test/old/testdir/test_popup.vim @@ -725,6 +725,9 @@ func Test_popup_and_preview_autocommand() au! au BufAdd * nested tab sball augroup END + " Let pythoncomplete follow the buffer's 'import os' (off by default + " since v9.2.0561) so 'os.' can be completed. + let g:pythoncomplete_allow_import = 1 set omnifunc=pythoncomplete#Complete call setline(1, 'import os') " make the line long @@ -747,6 +750,7 @@ func Test_popup_and_preview_autocommand() augroup END augroup! MyBufAdd bw! + unlet g:pythoncomplete_allow_import endfunc func s:run_popup_and_previewwindow_dump(lines, dumpfile)