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 756763 - Doesn't build with Python 3
Doesn't build with Python 3
Status: RESOLVED FIXED
Product: gobject-introspection
Classification: Platform
Component: build
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2015-10-17 20:31 UTC by Damien Grassart
Modified: 2015-10-19 22:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix python2/3 compatibility (2.80 KB, patch)
2015-10-17 20:34 UTC, Damien Grassart
reviewed Details | Review

Description Damien Grassart 2015-10-17 20:31:09 UTC
A few lines prevent building gobject-introspection with Python 3. I've fixed the parts that I found which error out during the build, and made sure the code still works under Python 2.7 (by passing PYTHON=/usr/bin/python2 to configure).
Comment 1 Damien Grassart 2015-10-17 20:34:58 UTC
Created attachment 313573 [details] [review]
Fix python2/3 compatibility
Comment 2 Colin Walters 2015-10-19 14:48:05 UTC
Review of attachment 313573 [details] [review]:

::: giscanner/ccompiler.py
@@ -237,3 @@
                                      extra_postargs=extra_postargs,
-                                     output_dir=source_str[tmpdir_idx + 1:
-                                                    source_str.rfind(os.sep)].encode('UTF-8'))

This looks like it's reverting a change made in d59b3827d2bb62c1ed4db8030ed9e8e753b7f52d - are you sure this still works with Python 3?  It appears to still work with 2.
Comment 3 Damien Grassart 2015-10-19 16:23:11 UTC
Encoding the string to utf-8 doesn't work in Python 3 because /usr/lib/python3.5/distutils/ccompiler.py explicitly checks (in _setup_compile()) that the value passed in output_dir is str or None. But in Python 3, str.encode() returns <class 'bytes'> (not <type 'str'> like in Python 2), which is why the build errors out with "'output_dir' must be a string or None".
Comment 4 Colin Walters 2015-10-19 22:00:03 UTC
(In reply to Damien Grassart from comment #3)
> Encoding the string to utf-8 doesn't work in Python 3 because
> /usr/lib/python3.5/distutils/ccompiler.py explicitly checks (in
> _setup_compile()) that the value passed in output_dir is str or None. But in
> Python 3, str.encode() returns <class 'bytes'> (not <type 'str'> like in
> Python 2), which is why the build errors out with "'output_dir' must be a
> string or None".

I see, I missed your additional `str`.  Makes sense, thanks!

https://git.gnome.org/browse/gobject-introspection/commit/?id=5341da3520ef513e5a7c49e2d8737bb3f2341a3d