GNOME Bugzilla – Bug 756763
Doesn't build with Python 3
Last modified: 2015-10-19 22:00:03 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).
Created attachment 313573 [details] [review] Fix python2/3 compatibility
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.
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".
(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