LeaderF
LeaderF copied to clipboard
mru crashes when using python2
- vim or neovim?
- [ ] vim
- [x] neovim
- Output of
vim --version
ornvim --version
: NVIM v0.5.0-dev - Output of
:echo has("python")
: 1 - Output of
:echo has("python3")
: 1 - Output of
:echo &pythondll
(only vim, not neovim): - Output of
:echo &pythonthreedll
(only vim, not neovim): - Output of
:py print(sys.version)
: 2.7.16 (default, Dec 21 2020, 23:00:36) [GCC Apple LLVM 12.0.0 (clang-1200.0.30.4) [+internal-os, ptrauth-isa=sign+stri - Output of
:py3 print(sys.version)
: 3.7.6 (default, Jan 8 2020, 13:42:34) [Clang 4.0.1 (tags/RELEASE_401/final)] - Output of
:echo g:Lf_Debug_Cmd
: - Output of
:echo g:Lf_FilesFromCache
: - Operating system:
- [ ] Linux
- [x] Mac OS X
- [ ] Windows
- [ ] Etc.
- Configurations related to LeaderF in vimrc:
let g:Lf_GtagsAutoGenerate = 1
let g:Lf_UseCache = 0
let g:Lf_PythonVersion = 2
let g:Lf_Gtagslabel = 'native-pygments'
let g:Lf_RgConfig = [
\ "--hidden",
\ "--no-ignore"
\ ]
let g:Lf_ExternalCommand = 'rg --files --no-ignore --hidden "%s"'
let g:Lf_PreviewInPopup = 1
let g:Lf_ShowHidden = 1
Describe your question, feature request, or bug.
Leaderf mru
always crashes when using python 2.
处理 function leaderf#Any#start[4]..leaderf#LfPy[1]..provider#python#Call 时发生错>
误:
第 18 行:
Error invoking 'python_execute' on channel 6 (python2-script-host):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/anyEx
pl.py", line 815, in start
the_args.start(arguments, *args, **kwargs)
File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/anyEx
pl.py", line 747, in _default_action
manager.startExplorer(win_pos[2:], *args, **kwargs)
File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manag
er.py", line 2238, in startExplorer
self.input()
File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manag
er.py", line 62, in deco
func(self, *args, **kwargs)
File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manag
er.py", line 2524, in input
self._search(cur_content)
File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manag
er.py", line 1071, in _search
self._fuzzySearch(content, is_continue, step)
File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manag
er.py", line 1496, in _fuzzySearch
self._highlight_method()
File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manag
er.py", line 1632, in _highlight
for line in content[:highlight_number:unit]])
SystemError: NULL result without error in PyObject_Call
BTW, there are other issues when I use python2 and some of them are related with manager.py:1632
. Python3 works fine for me.
Steps to reproduce
cd xxx
vim .
:Leaderf mru
Then type any character.
please reinstall the C extension and have a try.
doesn't work.
Also, if I use Leaderf File
with python2 and type anything, this error occurs
处理 function leaderf#Any#start[4]..leaderf#LfPy[1]..provider#python#Call 时发生错误:
第 18 行:
Error invoking 'python_execute' on channel 4 (python2-script-host):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/anyExpl.py", line 815, in start
the_args.start(arguments, *args, **kwargs)
File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/anyExpl.py", line 747, in _default_action
manager.startExplorer(win_pos[2:], *args, **kwargs)
File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/fileExpl.py", line 808, in startExplorer
super(FileExplManager, self).startExplorer(win_pos, *args, **kwargs)
File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 2298, in startExplorer
self.input()
File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 62, in deco
func(self, *args, **kwargs)
File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 2524, in input
self._search(cur_content)
File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 1071, in _search
self._fuzzySearch(content, is_continue, step)
File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 1496, in _fuzzySearch
self._highlight_method()
File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 1632, in _highlight
for line in content[:highlight_number:unit]])
UnicodeEncodeError: 'ascii' codec can't encode character u'\ue60b' in position 0: ordinal not in range(128)
I can fix it by modifying
https://github.com/Yggdroot/LeaderF/blob/86eaa396858a8da957d9f445e9d8bd4c0c304f96/autoload/leaderf/python/leaderf/manager.py#L1631
to getDigest(line).encode('utf8')
. Maybe they are related issues?
btw, Even I uninstall the C extension that SystemError
still occurs. I have checked by :echo g:Lf_fuzzyEngine_C
.
Could you show me your mru list please?
Also, if I use
Leaderf File
with python2 and type anything, this error occurs处理 function leaderf#Any#start[4]..leaderf#LfPy[1]..provider#python#Call 时发生错误: 第 18 行: Error invoking 'python_execute' on channel 4 (python2-script-host): Traceback (most recent call last): File "<string>", line 1, in <module> File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/anyExpl.py", line 815, in start the_args.start(arguments, *args, **kwargs) File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/anyExpl.py", line 747, in _default_action manager.startExplorer(win_pos[2:], *args, **kwargs) File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/fileExpl.py", line 808, in startExplorer super(FileExplManager, self).startExplorer(win_pos, *args, **kwargs) File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 2298, in startExplorer self.input() File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 62, in deco func(self, *args, **kwargs) File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 2524, in input self._search(cur_content) File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 1071, in _search self._fuzzySearch(content, is_continue, step) File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 1496, in _fuzzySearch self._highlight_method() File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 1632, in _highlight for line in content[:highlight_number:unit]]) UnicodeEncodeError: 'ascii' codec can't encode character u'\ue60b' in position 0: ordinal not in range(128)
I can fix it by modifying
https://github.com/Yggdroot/LeaderF/blob/86eaa396858a8da957d9f445e9d8bd4c0c304f96/autoload/leaderf/python/leaderf/manager.py#L1631
to
getDigest(line).encode('utf8')
. Maybe they are related issues?btw, Even I uninstall the C extension that
SystemError
still occurs. I have checked by:echo g:Lf_fuzzyEngine_C
.
This is a different issue.
Could you show me your mru list please?
bustub.svg "Documents/GitHub/15-445/bustub/logo/"
.clang-tidy "Documents/GitHub/15-445/bustub/third_party/"
.vimrc ".dotfiles/"
leaderf.vim ".vim/"
shortcuts.vim ".vim/"
signfy.vim ".vim/"
manager.py ".vim/plugged/LeaderF/autoload/leaderf/python/leaderf/"
colorschemeExpl.py ".vim/plugged/LeaderF/autoload/leaderf/python/leaderf/"
commandExpl.py ".vim/plugged/LeaderF/autoload/leaderf/python/leaderf/"
jumpsExpl.py ".vim/plugged/LeaderF/autoload/leaderf/python/leaderf/"
gruvbox_default.vim ".vim/plugged/LeaderF/autoload/leaderf/colorscheme/popup/"
Search_History.vim ".vim/plugged/LeaderF/autoload/leaderf/"
default.vim ".vim/plugged/LeaderF/autoload/leaderf/colorscheme/popup/"
powerline.vim ".vim/plugged/LeaderF/autoload/leaderf/colorscheme/"
default.vim ".vim/plugged/LeaderF/autoload/leaderf/colorscheme/"
popup.vim ".vim/plugged/LeaderF/autoload/leaderf/colorscheme/"
one.vim ".vim/plugged/LeaderF/autoload/leaderf/colorscheme/"
pre-applypatch.sample ".vim/plugged/LeaderF/.git/hooks/"
QfLocList.vim ".vim/plugged/LeaderF/autoload/leaderf/"
colorscheme.vim ".vim/plugged/LeaderF/autoload/leaderf/"
Filetype.vim ".vim/plugged/LeaderF/autoload/leaderf/"
Function.vim ".vim/plugged/LeaderF/autoload/leaderf/"
History.vim ".vim/plugged/LeaderF/autoload/leaderf/"
post-update.sample ".vim/plugged/LeaderF/.git/hooks/"
pre-receive.sample ".vim/plugged/LeaderF/.git/hooks/"
Window.vim ".vim/plugged/LeaderF/autoload/leaderf/"
Colors.vim ".vim/plugged/LeaderF/autoload/leaderf/"
Buffer.vim ".vim/plugged/LeaderF/autoload/leaderf/"
BufTag.vim ".vim/plugged/LeaderF/autoload/leaderf/"
pre-rebase.sample ".vim/plugged/LeaderF/.git/hooks/"
Gtags.vim ".vim/plugged/LeaderF/autoload/leaderf/"
Self.vim ".vim/plugged/LeaderF/autoload/leaderf/"
Help.vim ".vim/plugged/LeaderF/autoload/leaderf/"
File.vim ".vim/plugged/LeaderF/autoload/leaderf/"
Line.vim ".vim/plugged/LeaderF/autoload/leaderf/"
pre-push.sample ".vim/plugged/LeaderF/.git/hooks/"
Cmd_History.vim ".vim/plugged/LeaderF/autoload/leaderf/"
HEAD ".vim/plugged/LeaderF/.git/logs/refs/remotes/origin/"
Tag.vim ".vim/plugged/LeaderF/autoload/leaderf/"
Any.vim ".vim/plugged/LeaderF/autoload/leaderf/"
Command.vim ".vim/plugged/LeaderF/autoload/leaderf/"
Rg.vim ".vim/plugged/LeaderF/autoload/leaderf/"
Jumps.vim ".vim/plugged/LeaderF/autoload/leaderf/"
update.sample ".vim/plugged/LeaderF/.git/hooks/"
pre-commit.sample ".vim/plugged/LeaderF/.git/hooks/"
fsmonitor-watchman.sample ".vim/plugged/LeaderF/.git/hooks/"
leaderf.vim ".vim/plugged/LeaderF/autoload/"
HEAD ".vim/plugged/LeaderF/.git/refs/remotes/origin/"
FUNDING.yml ".vim/plugged/LeaderF/.github/"
leaderf.vim ".vim/plugged/LeaderF/plugin/"
leaderf.vim ".vim/plugged/LeaderF/syntax/"
gruvbox_material.vim ".vim/plugged/LeaderF/autoload/leaderf/colorscheme/popup/"
gruvbox_material.vim ".vim/plugged/LeaderF/autoload/leaderf/colorscheme/"
fuzzyMatch.pyc ".vim/plugged/LeaderF/autoload/leaderf/python/leaderf/"
fuzzyMatch.py ".vim/plugged/LeaderF/autoload/leaderf/python/leaderf/"
manager.pyc ".vim/plugged/LeaderF/autoload/leaderf/python/leaderf/"
mruExpl.pyc ".vim/plugged/LeaderF/autoload/leaderf/python/leaderf/"
mruExpl.py ".vim/plugged/LeaderF/autoload/leaderf/python/leaderf/"
mru.pyc ".vim/plugged/LeaderF/autoload/leaderf/python/leaderf/"
mru.py ".vim/plugged/LeaderF/autoload/leaderf/python/leaderf/"
prepare-commit-msg.sample ".vim/plugged/LeaderF/.git/hooks/"
fuzzyEngine.h ".vim/plugged/LeaderF/autoload/leaderf/fuzzyMatch_C/"
fuzzyEngine.c ".vim/plugged/LeaderF/autoload/leaderf/fuzzyMatch_C/"
fuzzyMatch.h ".vim/plugged/LeaderF/autoload/leaderf/fuzzyMatch_C/"
fuzzyMatch.c ".vim/plugged/LeaderF/autoload/leaderf/fuzzyMatch_C/"
mystdint.h ".vim/plugged/LeaderF/autoload/leaderf/fuzzyMatch_C/"
setup.py ".vim/plugged/LeaderF/autoload/leaderf/fuzzyMatch_C/"
applypatch-msg.sample ".vim/plugged/LeaderF/.git/hooks/"
master ".vim/plugged/LeaderF/.git/logs/refs/heads/"
commit-msg.sample ".vim/plugged/LeaderF/.git/hooks/"
Mru.vim ".vim/plugged/LeaderF/autoload/leaderf/"
master ".vim/plugged/LeaderF/.git/refs/heads/"
lfMru.vim ".vim/plugged/LeaderF/autoload/"
ISSUE_TEMPLATE.md ".vim/plugged/LeaderF/"
CHANGELOG.md ".vim/plugged/LeaderF/"
README.md ".vim/plugged/LeaderF/"
.vimrc "./"
tmp "./"
rgExpl.py ".vim/plugged/LeaderF/autoload/leaderf/python/leaderf/"
.gitignore ".vim/plugged/LeaderF/"
q2_long_name.sql "Documents/GitHub/15-445/hw1/"
q1_sample.sql "Documents/GitHub/15-445/hw1/"
q3_old_music_nations.sql "Documents/GitHub/15-445/hw1/"
description ".dotfiles/.git/"
e75a7f87f9b71f91b2ce5f7d6350e20b9581f2 ".dotfiles/.git/objects/59/"
leaderf.vim ".dotfiles/.vim/"
seq_scan_executor.cpp "Documents/GitHub/15-445/bustub/src/execution/"
shortcuts.vim ".dotfiles/.vim/"
I don't know why many leaderf files are in my list... What's the algorithm to determine the mru files?
After reinstalling the C extension, what is the result?
After reinstalling the C extension, what is the result?
Same result.
After reinstalling the C extension, what is the result?
Same result.
SystemError: NULL result without error in PyObject_Call ?
After reinstalling the C extension, what is the result?
Same result.
SystemError: NULL result without error in PyObject_Call ?
Yes.
What if the C extension is uninstalled?
What if the C extension is uninstalled?
Still same. But after removing all .pyc
files I got this error
Error invoking 'python_execute' on channel 6 (python2-script-host):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 62, in deco
func(self, *args, **kwargs)
File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 2512, in input
self._search(self._content)
File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 1071, in _search
self._fuzzySearch(content, is_continue, step)
File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 1430, in _fuzzySearch
fuzzy_match = FuzzyMatch(self._cli.pattern, encoding)
File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/fuzzyMatch.py", line 38, in __init__
self._pattern = Unicode(pattern, encoding)
File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/fuzzyMatch.py", line 27, in Unicode
return unicode(str, encoding, 'ignore')
TypeError: decoding Unicode is not supported
Easily fixed by modifying
https://github.com/Yggdroot/LeaderF/blob/86eaa396858a8da957d9f445e9d8bd4c0c304f96/autoload/leaderf/python/leaderf/fuzzyMatch.py#L25-L29
to
def Unicode(str, encoding):
try:
return unicode(str, encoding, 'ignore')
except ValueError:
return str
except TypeError:
return str
So I think C issues are also related with the string encoding of python2?
https://github.com/Yggdroot/LeaderF/blob/86eaa396858a8da957d9f445e9d8bd4c0c304f96/autoload/leaderf/python/leaderf/fuzzyMatch.py#L25-L29
to
def Unicode(str, encoding): try: return unicode(str, encoding, 'ignore') except ValueError: return str except TypeError: return str
Can this solution fix SystemError: NULL result without error in PyObject_Call ?
Can this solution fix SystemError: NULL result without error in PyObject_Call ?
No. But maybe I figure out what's wrong.
https://github.com/Yggdroot/LeaderF/blob/86eaa396858a8da957d9f445e9d8bd4c0c304f96/autoload/leaderf/python/leaderf/mruExpl.py#L144
I found here the first 2 characters of basename
are always missing. The prefix_len
is calculated wrong in python2 because of encoding of icons.
But there were still many issues with Chinese characters in python2. Finally I found my python2 default encoding is ascii
. Maybe that's why you don't hit some of my issues?
![Screenshot 2021-05-07 at 16 03 02](https://user-images.githubusercontent.com/44310559/117418192-b6d9c600-af4d-11eb-9c63-e9ff4ae99021.png)
All mentioned encoding errors fixed by
![Screenshot 2021-05-07 at 16 09 25](https://user-images.githubusercontent.com/44310559/117418961-9c541c80-af4e-11eb-8a36-64a0442c4d49.png)
Tested in python2 and python3. If you think it's ok I will give a PR.
Is the change of def webDevIconsStrLen()
necessary?
PR is welcome.
Is the change of
def webDevIconsStrLen()
necessary?PR is welcome.
Yes. Because you use prefix_len
to truncate line
which is type unicode
. But it is calculated with type str
.
py2 on mymachine doesn't have this issue.
I don't know... It opens the wrong file when using py2 on my machine
![Screenshot 2021-05-07 at 21 08 29](https://user-images.githubusercontent.com/44310559/117454141-6035b180-af78-11eb-8fa1-ede98893fa9a.png)
Can you check the type that webDevIconsString()
returns and line
? Mine are str
and unicode
respectively.
![Screenshot 2021-05-07 at 21 18 12](https://user-images.githubusercontent.com/44310559/117455458-c969f480-af79-11eb-88d7-ea26853e8682.png)
This fix also works for me.
Mine is also
>>> import sys
>>> sys.getdefaultencoding()
'ascii'
>>>
what's &encoding?
what's &encoding?
sry what do you mean?
Maybe the same reason as #810 .
Works for mru
. But this still exists.
Also, if I use
Leaderf File
with python2 and type anything, this error occurs处理 function leaderf#Any#start[4]..leaderf#LfPy[1]..provider#python#Call 时发生错误: 第 18 行: Error invoking 'python_execute' on channel 4 (python2-script-host): Traceback (most recent call last): File "<string>", line 1, in <module> File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/anyExpl.py", line 815, in start the_args.start(arguments, *args, **kwargs) File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/anyExpl.py", line 747, in _default_action manager.startExplorer(win_pos[2:], *args, **kwargs) File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/fileExpl.py", line 808, in startExplorer super(FileExplManager, self).startExplorer(win_pos, *args, **kwargs) File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 2298, in startExplorer self.input() File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 62, in deco func(self, *args, **kwargs) File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 2524, in input self._search(cur_content) File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 1071, in _search self._fuzzySearch(content, is_continue, step) File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 1496, in _fuzzySearch self._highlight_method() File "/Users/xutianshu/.vim/plugged/LeaderF/autoload/leaderf/python/leaderf/manager.py", line 1632, in _highlight for line in content[:highlight_number:unit]]) UnicodeEncodeError: 'ascii' codec can't encode character u'\ue60b' in position 0: ordinal not in range(128)
I can fix it by modifying https://github.com/Yggdroot/LeaderF/blob/86eaa396858a8da957d9f445e9d8bd4c0c304f96/autoload/leaderf/python/leaderf/manager.py#L1631
to
getDigest(line).encode('utf8')
. Maybe they are related issues? btw, Even I uninstall the C extension thatSystemError
still occurs. I have checked by:echo g:Lf_fuzzyEngine_C
.This is a different issue.
Did you add set encoding=utf-8
in your vimrc?
yep.