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
--- pygments_parser.py.orig     2017-01-07 23:22:40.000000000 +0900
+++ pygments_parser.py  2017-03-11 20:54:28.266765014 +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():
_______________________________________________
Bug-global mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-global

Reply via email to