After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 781994 - fixxref mixes and matches strings and bytes
fixxref mixes and matches strings and bytes
Status: RESOLVED FIXED
Product: gtk-doc
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-doc maintainers
gtk-doc maintainers
Depends on:
Blocks:
 
 
Reported: 2017-04-30 20:35 UTC by Ernestas Kulik
Modified: 2017-06-02 13:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fixxref: don’t mix and match bytes and strings (2.35 KB, patch)
2017-04-30 20:39 UTC, Ernestas Kulik
committed Details | Review
don’t mix and match bytes and strings (2.70 KB, patch)
2017-05-28 18:05 UTC, Stefan Sauer (gstreamer, gtkdoc dev)
none Details | Review

Description Ernestas Kulik 2017-04-30 20:35:19 UTC
I get this trace when building gst-plugins-base:

Error in gtkdoc helper script:
'gtkdoc-fixxref' failed with status 1
Traceback (most recent call last):
  • File "/home/ernestas/jhbuild/install/bin/gtkdoc-fixxref", line 59 in <module>
    fixxref.Run(options)
  • File "/home/ernestas/jhbuild/install/share/gtk-doc/python/gtkdoc/fixxref.py", line 113 in Run
    FixCrossReferences(options)
  • File "/home/ernestas/jhbuild/install/share/gtk-doc/python/gtkdoc/fixxref.py", line 216 in FixCrossReferences
    FixHTMLFile(options, full_entry)
  • File "/home/ernestas/jhbuild/install/share/gtk-doc/python/gtkdoc/fixxref.py", line 239 in FixHTMLFile
    repl_func, content, flags=re.DOTALL)
  • File "/usr/lib/python3.6/re.py", line 191 in sub
    return _compile(pattern, flags).sub(repl, string, count)
  • File "/home/ernestas/jhbuild/install/share/gtk-doc/python/gtkdoc/fixxref.py", line 236 in repl_func
    return HighlightSource(options, m.group(1), m.group(2))
  • File "/home/ernestas/jhbuild/install/share/gtk-doc/python/gtkdoc/fixxref.py", line 339 in HighlightSource
    f.write(source)
  • File "/usr/lib/python3.6/tempfile.py", line 483 in func_wrapper
    return func(*args, **kwargs)
TypeError: a bytes-like object is required, not 'str'

---

After fixing that one I get this:

Error in gtkdoc helper script:
'gtkdoc-fixxref' failed with status 1
Traceback (most recent call last):
  File "/home/ernestas/jhbuild/install/bin/gtkdoc-fixxref", line 59, in <module>
    fixxref.Run(options)
  File "/home/ernestas/jhbuild/install/share/gtk-doc/python/gtkdoc/fixxref.py", line 113, in Run
    FixCrossReferences(options)
  File "/home/ernestas/jhbuild/install/share/gtk-doc/python/gtkdoc/fixxref.py", line 216, in FixCrossReferences
    FixHTMLFile(options, full_entry)
  File "/home/ernestas/jhbuild/install/share/gtk-doc/python/gtkdoc/fixxref.py", line 239, in FixHTMLFile
    repl_func, content, flags=re.DOTALL)
  File "/usr/lib/python3.6/re.py", line 191, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/home/ernestas/jhbuild/install/share/gtk-doc/python/gtkdoc/fixxref.py", line 236, in repl_func
    return HighlightSource(options, m.group(1), m.group(2))
  File "/home/ernestas/jhbuild/install/share/gtk-doc/python/gtkdoc/fixxref.py", line 351, in HighlightSource
    highlighted_source = re.sub(r'^<\!-- .*? -->', '', highlighted_source, flags=re.MULTILINE | re.DOTALL)
  File "/usr/lib/python3.6/re.py", line 191, in sub
    return _compile(pattern, flags).sub(repl, string, count)
TypeError: cannot use a string pattern on a bytes-like object
Comment 1 Ernestas Kulik 2017-04-30 20:39:31 UTC
Created attachment 350774 [details] [review]
fixxref: don’t mix and match bytes and strings

NamedTemporaryFile() opens the file in binary mode by default, which
doesn’t work, since strings are being written to it. Additionally, the
code tries to perform a regex substitution on subprocess.check_output()
return value, which is not a string.

Signed-off-by: Ernestas Kulik <ernestask@gnome.org>
Comment 2 Ernestas Kulik 2017-04-30 20:42:24 UTC
Patch tested only to the extent of making sure that building docs does not make the script throw a fit.
Comment 3 Stefan Sauer (gstreamer, gtkdoc dev) 2017-05-10 19:07:38 UTC
Review of attachment 350774 [details] [review]:

Thanks!
Comment 4 Ernestas Kulik 2017-05-11 11:06:05 UTC
Attachment 350774 [details] pushed as 7946cdf - fixxref: don’t mix and match bytes and strings
Comment 5 Ting-Wei Lan 2017-05-11 14:20:48 UTC
Attachment 350774 [details] seems to cause build failure for glib:

  DOC   Fixing cross-references
html/glib-Lexical-Scanner.html:1191: warning: no link for: "G-TOKEN-LAST:CAPS" -> (<code class="literal">G_TOKEN_LAST</code>).
Traceback (most recent call last):
  • File "/home/lantw44/gnome/devinstall/bin/gtkdoc-fixxref", line 59 in <module>
    fixxref.Run(options)
  • File "/home/lantw44/gnome/devinstall/share/gtk-doc/python/gtkdoc/fixxref.py", line 113 in Run
    FixCrossReferences(options)
  • File "/home/lantw44/gnome/devinstall/share/gtk-doc/python/gtkdoc/fixxref.py", line 216 in FixCrossReferences
    FixHTMLFile(options, full_entry)
  • File "/home/lantw44/gnome/devinstall/share/gtk-doc/python/gtkdoc/fixxref.py", line 239 in FixHTMLFile
    repl_func, content, flags=re.DOTALL)
  • File "/usr/lib64/python2.7/re.py", line 155 in sub
    return _compile(pattern, flags).sub(repl, string, count)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 1020: ordinal not in range(128)
Makefile:944: recipe for target 'html-build.stamp' failed
Comment 6 Ernestas Kulik 2017-05-11 15:28:15 UTC
(In reply to Ting-Wei Lan from comment #5)
> Attachment 350774 [details] seems to cause build failure for glib:
> 
>   DOC   Fixing cross-references
> html/glib-Lexical-Scanner.html:1191: warning: no link for:
> "G-TOKEN-LAST:CAPS" -> (<code class="literal">G_TOKEN_LAST</code>).
> Traceback (most recent call last):

I’ll see what I can do about it.
Comment 7 Ernestas Kulik 2017-05-11 19:00:28 UTC
Reverted the commit. It’s encodings all the way down. Forcing utf-8 for all files (codecs.open()) sort of works, but then it breaks with Python 3, because you can’t specify the encoding for temp files in Python 2 and we’re back at square one.

A bit too much for one evening.
Comment 8 Ernestas Kulik 2017-05-12 10:43:15 UTC
(In reply to Ting-Wei Lan from comment #5)
> Attachment 350774 [details] seems to cause build failure for glib:
> 
>   DOC   Fixing cross-references
> html/glib-Lexical-Scanner.html:1191: warning: no link for:
> "G-TOKEN-LAST:CAPS" -> (<code class="literal">G_TOKEN_LAST</code>).
> Traceback (most recent call last):

Are you sure that it’s my patch, though? It’s broken for me either way with Python 3.
Comment 9 Ting-Wei Lan 2017-05-12 12:51:46 UTC
gtkdoc-fixxref uses python 2.7.13 on my system because python is a symlink to python2. I saw the problem with commit 7946cdf, and 'git checkout' to the previous commit fixed it.
Comment 10 Stefan Sauer (gstreamer, gtkdoc dev) 2017-05-12 19:48:56 UTC
I'll take a look.
Comment 11 Stefan Sauer (gstreamer, gtkdoc dev) 2017-05-28 18:05:02 UTC
Created attachment 352730 [details] [review]
don’t mix and match bytes and strings

New attempt. This also works for python2. Ernestas, could you check if this still makes things work for you?
Comment 12 Ernestas Kulik 2017-05-28 19:12:59 UTC
(In reply to Stefan Sauer (gstreamer, gtkdoc dev) from comment #11)
> Created attachment 352730 [details] [review] [review]
> don’t mix and match bytes and strings
> 
> New attempt. This also works for python2. Ernestas, could you check if this
> still makes things work for you?

I tried, but bug 783178 happened. :|
Comment 13 Stefan Sauer (gstreamer, gtkdoc dev) 2017-05-29 18:04:12 UTC
Ernestas, I've pushed a fix for that. I need to figure a way to test with both python2 and python3 ...
Comment 14 Stefan Sauer (gstreamer, gtkdoc dev) 2017-06-02 06:21:27 UTC
I am now working with two checkout one configurred for py2 and one for py3. Will take care of this.
Comment 15 Stefan Sauer (gstreamer, gtkdoc dev) 2017-06-02 06:38:39 UTC
commit b9dfd5e2135fb84579c8c5971419b920bedd5bfc
Author: Ernestas Kulik <ernestask@gnome.org>
Date:   Sun May 28 20:02:29 2017 +0200

    fixxref: fix bytestring handling for python 3
    
    NamedTemporaryFile() opens the file in binary mode by default, which
    doesn’t work, since strings are being written to it. Additionally, the
    code tries to perform a regex substitution on subprocess.check_output()
    return value, which is not a string.
Comment 16 Ernestas Kulik 2017-06-02 06:58:26 UTC
All the recent fixes fixed the issue for me. Thanks!
Comment 17 Stefan Sauer (gstreamer, gtkdoc dev) 2017-06-02 10:33:04 UTC
Thanks for testing, really appreciated!
Comment 18 Ting-Wei Lan 2017-06-02 13:16:31 UTC
gtkdoc-fixxref failed when building gtk3:

Makefile:968: recipe for target 'html-build.stamp' failed
gmake: [html-build.stamp] Error 1 (ignored)
gtkdoc-fixxref --module=gdk3 --module-dir=html --html-dir=/home/lantw44/gnome/devinstall/share/gtk-doc/html --extra-dir=/home/lantw44/gnome/devinstall/share/gtk-doc/html/gobject --extra-dir=/home/lantw44/gnome/devinstall/share/gtk-doc/html/glib --extra-dir=/usr/share/gtk-doc/html/cairo
html/gdk3-Visuals.html:389: warning: no link for: "api-index-2.22" -> (2.22).
html/gdk3-Visuals.html:869: warning: no link for: "api-index-2.2" -> (2.2).
html/GdkScreen.html:466: warning: no link for: "api-index-2.8" -> (2.8).
html/GdkScreen.html:499: warning: no link for: "api-index-2.10" -> (2.10).
html/GdkScreen.html:896: warning: no link for: "api-index-2.20" -> (2.20).
html/GdkScreen.html:1137: warning: no link for: "api-index-2.14" -> (2.14).
html/GdkScreen.html:1348: warning: no link for: "PangoContext" -> (<span class="type">PangoContext</span>).
html/GdkScreen.html:1413: warning: no link for: "PangoFontDescription" -> (<span class="type">PangoFontDescription</span>).
html/gdk3-Cairo-Interaction.html:170: warning: no link for: "GdkPixbufs" -> (<span class="type">GdkPixbufs</span>).
html/gdk3-Cairo-Interaction.html:532: warning: no link for: "GdkPixbuf" -> (<span class="type">GdkPixbuf</span>).
html/gdk3-Cairo-Interaction.html:537: warning: no link for: "CAIRO-EXTEND-NONE:CAPS" -> (<code class="literal">CAIRO_EXTEND_NONE</code>).
html/gdk3-Cairo-Interaction.html:632: warning: no link for: "api-index-2.24" -> (2.24).
html/gdk3-Cairo-Interaction.html:786: warning: no link for: "GL-RENDERBUFFER:CAPS" -> (<span class="type">GL_RENDERBUFFER</span>).
html/gdk3-Cairo-Interaction.html:787: warning: no link for: "GL-TEXTURE:CAPS" -> (<span class="type">GL_TEXTURE</span>).
html/gdk3-Threads.html:226: warning: no link for: "G-THREADS-ENABLED:CAPS" -> (<span class="type">G_THREADS_ENABLED</span>).
html/gdk3-Threads.html:337: warning: no link for: "api-index-2.4" -> (2.4).
html/gdk3-Threads.html:376: warning: no link for: "api-index-2.12" -> (2.12).
Traceback (most recent call last):
  • File "/home/lantw44/gnome/devinstall/bin/gtkdoc-fixxref", line 59 in <module>
    fixxref.Run(options)
  • File "/home/lantw44/gnome/devinstall/share/gtk-doc/python/gtkdoc/fixxref.py", line 114 in Run
    FixCrossReferences(options)
  • File "/home/lantw44/gnome/devinstall/share/gtk-doc/python/gtkdoc/fixxref.py", line 217 in FixCrossReferences
    FixHTMLFile(options, full_entry)
  • File "/home/lantw44/gnome/devinstall/share/gtk-doc/python/gtkdoc/fixxref.py", line 242 in FixHTMLFile
    repl_func, content, flags=re.DOTALL)
  • File "/usr/lib64/python2.7/re.py", line 155 in sub
    return _compile(pattern, flags).sub(repl, string, count)
  • File "/home/lantw44/gnome/devinstall/share/gtk-doc/python/gtkdoc/fixxref.py", line 239 in repl_func
    return HighlightSource(options, m.group(1), m.group(2))
  • File "/home/lantw44/gnome/devinstall/share/gtk-doc/python/gtkdoc/fixxref.py", line 345 in HighlightSource
    f.write(source)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u23a1' in position 31: ordinal not in range(128)
Makefile:968: recipe for target 'html-build.stamp' failed
gmake: *** [html-build.stamp] Error 1