[gobject-introspection] giscanner: Fix python2/3 compatibility
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] giscanner: Fix python2/3 compatibility
- Date: Mon, 19 Oct 2015 21:59:47 +0000 (UTC)
commit 5341da3520ef513e5a7c49e2d8737bb3f2341a3d
Author: Damien Grassart <damien grassart com>
Date: Sat Oct 17 20:39:12 2015 +0200
giscanner: Fix python2/3 compatibility
This allows building in both Python 2 and 3 by fixing a few
text/binary ambiguities and using "as" in an except clause.
https://bugzilla.gnome.org/show_bug.cgi?id=756763
giscanner/ccompiler.py | 4 ++--
giscanner/dumper.py | 2 +-
giscanner/sourcescanner.py | 10 +++++-----
3 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py
index 2f02bfc..224c3e5 100644
--- a/giscanner/ccompiler.py
+++ b/giscanner/ccompiler.py
@@ -235,8 +235,8 @@ class CCompiler(object):
macros=macros,
include_dirs=includes,
extra_postargs=extra_postargs,
- output_dir=source_str[tmpdir_idx + 1:
- source_str.rfind(os.sep)].encode('UTF-8'))
+ output_dir=str(source_str[tmpdir_idx + 1:
+ source_str.rfind(os.sep)]))
def link(self, output, objects, lib_args):
# Note: This is used for non-libtool builds only!
diff --git a/giscanner/dumper.py b/giscanner/dumper.py
index 5bc48ad..f9c2a43 100644
--- a/giscanner/dumper.py
+++ b/giscanner/dumper.py
@@ -282,7 +282,7 @@ class DumpCompiler(object):
# this embedding is required, the build will fail anyway, as
# the dumper program will likely fail to run, and this means
# something went wrong with the build.
- except LinkError, e:
+ except LinkError as e:
if self._compiler.check_is_msvc():
msg = str(e)
diff --git a/giscanner/sourcescanner.py b/giscanner/sourcescanner.py
index 9a591e1..049ae16 100644
--- a/giscanner/sourcescanner.py
+++ b/giscanner/sourcescanner.py
@@ -314,10 +314,10 @@ class SourceScanner(object):
def _write_preprocess_src(self, fp, defines, undefs, filenames):
# Write to the temp file for feeding into the preprocessor
for define in defines:
- fp.write('#ifndef %s\n' % (define, ))
- fp.write('# define %s\n' % (define, ))
- fp.write('#endif\n')
+ fp.write(('#ifndef %s\n' % (define, )).encode())
+ fp.write(('# define %s\n' % (define, )).encode())
+ fp.write('#endif\n'.encode())
for undef in undefs:
- fp.write('#undef %s\n' % (undef, ))
+ fp.write(('#undef %s\n' % (undef, )).encode())
for filename in filenames:
- fp.write('#include <%s>\n' % (filename, ))
+ fp.write(('#include <%s>\n' % (filename, )).encode())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]