Closed lyuts closed 6 years ago
subprocess.run() is only available with python 3.5 or later.
This worked for me for python 2 (assumingly - but untested - also for python 3).
Let me know, whether you are interested in supporting python2 and I create a pull request.
diff --git a/plugin/vimrtags.py b/plugin/vimrtags.py
index 5c73901..c4a8691 100644
--- a/plugin/vimrtags.py
+++ b/plugin/vimrtags.py
@@ -19,15 +19,16 @@ def get_identifier_beginning():
return column + 1
def run_rc_command(arguments, content = None):
- r = subprocess.run('rc ' + arguments, input = content,
- stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True,
- encoding = 'utf-8')
+ r = subprocess.Popen('rc ' + arguments, stdin = subprocess.PIPE,
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell = True)
+
+ stdout, stderr = r.communicate(content)
if r.returncode != 0:
- logging.debug(r.stderr)
+ logging.debug(stderr)
return None
- return r.stdout
+ return stdout
I get similar problem when try to use auto-completion,
Error detected while processing function RtagsCompleteFunc[2]..<SNR>22_RtagsCompleteFunc[13]..<SNR>22_Pyeval:
line 1:
Traceback (most recent call last):
Press ENTER or type command to continue
Error detected while processing function RtagsCompleteFunc[2]..<SNR>22_RtagsCompleteFunc[13]..<SNR>22_Pyeval:
line 1:
File "<string>", line 1, in <module>
Press ENTER or type command to continue
Error detected while processing function RtagsCompleteFunc[2]..<SNR>22_RtagsCompleteFunc[13]..<SNR>22_Pyeval:
line 1:
File "/u/user/.vim/bundle_cpp/vim-rtags/plugin/vimrtags.py", line 78, in send_completion_request
Press ENTER or type command to continue
Error detected while processing function RtagsCompleteFunc[2]..<SNR>22_RtagsCompleteFunc[13]..<SNR>22_Pyeval:
line 1:
content = run_rc_command(cmd, content)
Press ENTER or type command to continue
Error detected while processing function RtagsCompleteFunc[2]..<SNR>22_RtagsCompleteFunc[13]..<SNR>22_Pyeval:
line 1:
File "/u/user/.vim/bundle_cpp/vim-rtags/plugin/vimrtags.py", line 22, in run_rc_command
Press ENTER or type command to continue
Error detected while processing function RtagsCompleteFunc[2]..<SNR>22_RtagsCompleteFunc[13]..<SNR>22_Pyeval:
line 1:
r = subprocess.run('rc ' + arguments, input = content,
Press ENTER or type command to continue
Error detected while processing function RtagsCompleteFunc[2]..<SNR>22_RtagsCompleteFunc[13]..<SNR>22_Pyeval:
line 1:
AttributeError: 'module' object has no attribute 'run'
Press ENTER or type command to continue
Error detected while processing function RtagsCompleteFunc[2]..<SNR>22_RtagsCompleteFunc[13]..<SNR>22_Pyeval:
line 1:
E858: Eval did not return a valid python object
@metti , I would love to have support for both python versions. I'm trying to figure out what's the proper way of having plugin python agnostic. If you have experience with this it would be helpful. So far it seems like both pythons have subprocess.call
, maybe I can switch to it.
We've added handling of different python/subprocess versions. Resolving.
Invokingrd fails with:
Error detected while processing function rtags#Diagnostics..83_Pyeval:", line 1, in
line 1:
Traceback (most recent call last):
File "
File "/home/user/.vim/bundle/vim-rtags/plugin/vimrtags.py", line 150, in get_diagnostics
content = run_rc_command(cmd, content)
File "/home/user/.vim/bundle/vim-rtags/plugin/vimrtags.py", line 22, in run_rc_command
r = subprocess.run('rc ' + arguments, input = content,
AttributeError: 'module' object has no attribute 'run'
E858: Eval did not return a valid python object