bug-global
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [python3 only] when use "--gtagslabel=pygements", gtags don't output


From: ishigane
Subject: Re: [python3 only] when use "--gtagslabel=pygements", gtags don't output (C language) function names into GTAGS
Date: Sat, 11 Mar 2017 22:12:56 +0900
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

Shigio and Jason, Thank you for your reply.

I found that subprocess#Popen do a different behavior on Windows or not.
This issue occurs only Windows.

I wrote a test code, and tried on Windows10 and Debian stretch(currently, my unix-like machine is Debian only).

------------------
import subprocess
import sys

cmd = b'whoami'

p = subprocess.Popen(cmd, shell=True,
                stdout=subprocess.PIPE, stderr=subprocess.PIPE)

if p.wait() == 0:
    print(p.stdout.readline().rstrip())
------------------

result:
Windows10 + python 3.6.0 -> TypeError: argument of type 'int' is not iterable
  Debian stretch + python 3.5.3 -> worker
  (worker = user name)

On Windows, subprocess#Popen rejects byte type argument. But on Linux, subprocess#Popen accepts byte type.
I rechecked "path"(in handle_requests function). Value is like that.

Windows: b'ctags'
Debian: b'/usr/bin/ctags'



I rewrite a patch for encoding='latin1' and returning str type value.
I checked the patch, Windows/Debian + python2/3 (4 patterns). Target is "test.c"(same as previos mail).
gtags outs function name into GTAGS at every pattern.

But I don't have macintosh(I cannot check MacOS X). So if this patch is rejected, that wouldn't be a problem.

--- pygments_parser.py.orig     2017-01-13 12:32:06 +0900
+++ pygments_parser.py  2017-03-11 20:48:42 +0900
@@ -238,7 +238,10 @@
     p = subprocess.Popen("gtags --config=ctagscom", shell=True,
                 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     if p.wait() == 0:
-        path = p.stdout.readline().rstrip()
+        if sys.version_info < (3,):
+            path = p.stdout.readline().rstrip()
+        else:
+ path = io.TextIOWrapper(p.stdout, encoding='latin1').readline().rstrip()
     return path

 def main():

Thank you for reading(Thank you for being patient with my bad English).

Seigo Ishigane

Attachment: fix_path.diff
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]