Closed fcying closed 6 years ago
after modify def raise_ex()
to class raise_ex()
, it can raise the right log, it's abnormal by use let g:ncm2#matcher = 'substrfuzzy'
, if I use default matcher, it work fine.
diff --git a/pythonx/ncm2_pyclang_proc.py b/pythonx/ncm2_pyclang_proc.py
index d25eaee..fce4ad6 100644
--- a/pythonx/ncm2_pyclang_proc.py
+++ b/pythonx/ncm2_pyclang_proc.py
@@ -69,7 +69,7 @@ class Source(Ncm2Source):
except Exception as ex:
from neovim import Nvim
nvim = self.nvim # type: Nvim
- def raise_ex():
+ class raise_ex():
raise ex
nvim.async_call(raise_ex)
finally:
[ncm2_pyclang_proc@yarp] Exception in thread Thread-1:
[ncm2_pyclang_proc@yarp] Traceback (most recent call last):
[ncm2_pyclang_proc@yarp] File "/home/fcying/.pyenv/versions/3.6-dev/lib/python3.6/threading.py", line 916, in _bootstrap_inner
[ncm2_pyclang_proc@yarp] self.run()
[ncm2_pyclang_proc@yarp] File "/home/fcying/.pyenv/versions/3.6-dev/lib/python3.6/threading.py", line 864, in run
[ncm2_pyclang_proc@yarp] self._target(*self._args, **self._kwargs)
[ncm2_pyclang_proc@yarp] File "/home/fcying/.vim/plugged/ncm2-pyclang/pythonx/ncm2_pyclang_proc.py", line 72, in worker_loop
[ncm2_pyclang_proc@yarp] class raise_ex():
[ncm2_pyclang_proc@yarp] File "/home/fcying/.vim/plugged/ncm2-pyclang/pythonx/ncm2_pyclang_proc.py", line 73, in raise_ex
[ncm2_pyclang_proc@yarp] raise ex
[ncm2_pyclang_proc@yarp] File "/home/fcying/.vim/plugged/ncm2-pyclang/pythonx/ncm2_pyclang_proc.py", line 65, in worker_loop
[ncm2_pyclang_proc@yarp] task()
[ncm2_pyclang_proc@yarp] File "/home/fcying/.vim/plugged/ncm2-pyclang/pythonx/ncm2_pyclang_proc.py", line 333, in <lambda>
[ncm2_pyclang_proc@yarp] lambda: self.on_complete_task(context, data, lines)])
[ncm2_pyclang_proc@yarp] File "/home/fcying/.vim/plugged/ncm2-pyclang/pythonx/ncm2_pyclang_proc.py", line 395, in on_complete_task
[ncm2_pyclang_proc@yarp] if not matcher(base, item):
[ncm2_pyclang_proc@yarp] File "/home/fcying/.vim/plugged/ncm2/pythonx/ncm2_matcher/substrfuzzy.py", line 100, in match
[ncm2_pyclang_proc@yarp] hl = fuzzy_match(b, m[key], chcmp)
[ncm2_pyclang_proc@yarp] File "/home/fcying/.vim/plugged/ncm2/pythonx/ncm2_matcher/substrfuzzy.py", line 18, in fuzzy_match
[ncm2_pyclang_proc@yarp] return substr_fuzzy_match(b, s, abbrs, chcmp)
[ncm2_pyclang_proc@yarp] File "/home/fcying/.vim/plugged/ncm2/pythonx/ncm2_matcher/substrfuzzy.py", line 54, in substr_fuzzy_match
[ncm2_pyclang_proc@yarp] start = abbrs[0]
[ncm2_pyclang_proc@yarp] IndexError: list index out of range
[ncm2_pyclang_proc@yarp] Traceback (most recent call last):
[ncm2_pyclang_proc@yarp] File "/home/fcying/.vim/plugged/ncm2-pyclang/pythonx/ncm2_pyclang_proc.py", line 73, in raise_ex
[ncm2_pyclang_proc@yarp] raise ex
[ncm2_pyclang_proc@yarp] TypeError: exceptions must derive from BaseException
after modify def raise_ex() to class raise_ex(), it can raise the right log
Why ?
https://www.cnblogs.com/bidepanpan/p/7115153.html
TypeError: exceptions must derive from BaseException
异常必须从基础异常类中派生。然后看了下自己的第一行。用的是def,这是创建了一个方法。。而不是一个类,简单的语法错误。只要将第一行的def改成class
when I write a struct var in func parameter, pop up error. write same word in new line work fine.
reproduce way:
clang_test.zip