[python3 only] when use "--gtagslabel=pygements", gtags don't output (C language) function names into GTAGS

ishigane <[email protected]>
Newsgroups gmane.comp.gnu.global.bugs
Message-ID <[email protected]>
Dear all,

It might be a bug? I send a report.
Target is "*.c"(C language file).

When run "gtags" with "--gtagslabel=pygments" option, GTAGS file don't 
have any function names.
CTagsParser (at "share/gtags/script/pygments_parser.py") failed to 
initialize, gtags only use pygments.

This issue occurs only using python3. In the case of python 2.7.13, no 
problem.

environments:
    Windows10 Pro x64
    global 6.5.6 (http://adoxa.altervista.org/global/)
    python 3.6.0 x64 + pygments 2.2.0
    exuberant ctags 5.8 (patched, 
http://hp.vector.co.jp/authors/VA025040/ctags/)

Instructions:
1. I prepared "test.c". Content is like below.
----------
#include <stdio.h>

void test() {
}

int main(int argc, **char argv) {
	return 0;
}
-----------

2. gtags --gtagslabel=pygments
3. gtags -d GTAGS

expected result(same as python2):
   __.COMPNAME     __.COMPNAME
   __.COMPRESS     __.COMPRESS ddefine ttypedef
   __.VERSION      __.VERSION 6
main    1 @n 6 int @n(int argc, **char argv) {
test    1 @n 3 void @n() {

actual result(python3):
   __.COMPNAME     __.COMPNAME
   __.COMPRESS     __.COMPRESS ddefine ttypedef
   __.VERSION      __.VERSION 6

cause:
"share/gtags/script/pygments_parser.py".

At handle_requests(), CtagsParser failed to initialize.
At CtagsParser.__init__, subprocess.Popen() failed.

Because of "ctags_command"(argument of CtagsParser.__init__) is byte type.

patch:
--- pygments_parser.py.orig	2017-01-13 12:32:06 +0900
+++ pygments_parser.py	2017-03-09 18:44:25 +0900
@@ -239,6 +239,8 @@
                   stdout=subprocess.PIPE, stderr=subprocess.PIPE)
       if p.wait() == 0:
           path = p.stdout.readline().rstrip()
+    if sys.version_info >= (3, ):
+        path = path.decode()
       return path

   def main():

I don't know well about python(is checking/converting really ok?), it 
might be exists more better way.

Regards,
Seigo Ishigane

_______________________________________________
Bug-global mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-global
decode_path.diff (text/plain, 364 B)
--- pygments_parser.py.orig	2017-01-13 12:32:06 +0900
+++ pygments_parser.py	2017-03-09 18:44:25 +0900
@@ -239,6 +239,8 @@
                 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     if p.wait() == 0:
         path = p.stdout.readline().rstrip()
+    if sys.version_info >= (3, ):
+        path = path.decode()
     return path
 
 def main():
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.