From 440fd37dfa365bc3d9114fc40ebf022875cd6aee Mon Sep 17 00:00:00 2001 From: Thomas Nagy Date: Tue, 8 May 2012 19:01:30 +0200 Subject: [PATCH] Issue 1164 --- demos/subst/test.pc.in | 2 +- demos/subst/wscript | 1 + waflib/TaskGen.py | 13 +++++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/demos/subst/test.pc.in b/demos/subst/test.pc.in index 66818564..32fe742f 100644 --- a/demos/subst/test.pc.in +++ b/demos/subst/test.pc.in @@ -1,5 +1,5 @@ Name: test -Description: bork bork bork! +Description: ПРИЛОЖЕНИЕ Version: @VERSION@ Libs: -L${libdir} -lgnaa @LIBS@ @XPM_LIBS@ @LIBICONV@ Cflags: -I${includedir} @XPM_CFLAGS@ diff --git a/demos/subst/wscript b/demos/subst/wscript index 0922ca11..ebe975c9 100644 --- a/demos/subst/wscript +++ b/demos/subst/wscript @@ -18,6 +18,7 @@ def build(bld): features = 'subst', # the feature 'subst' overrides the source/target processing source = 'foo.in', # list of string or nodes target = 'foo.txt', # list of strings or nodes + encoding = 'ascii', # file encoding for python3, default is ISO8859-1 install_path = '/tmp/uff/', # installation path, optional chmod = Utils.O755, # installation mode, optional PREFIX = bld.env.PREFIX, # variables to use in the substitution diff --git a/waflib/TaskGen.py b/waflib/TaskGen.py index 00b67d30..1bea9aa3 100644 --- a/waflib/TaskGen.py +++ b/waflib/TaskGen.py @@ -665,7 +665,11 @@ class subst_pc(Task.Task): os.chmod(self.outputs[0].abspath(), self.generator.chmod) return - code = self.inputs[0].read() + code = self.inputs[0].read('rb') + try: + code = code.decode(getattr(self.generator, 'encoding', 'ISO8859-1')) + except AttributeError: + pass # replace all % by %% to prevent errors by % signs code = code.replace('%', '%%') @@ -688,7 +692,12 @@ class subst_pc(Task.Task): tmp = getattr(self.generator, x, '') or self.env.get_flat(x) or self.env.get_flat(x.upper()) d[x] = str(tmp) - self.outputs[0].write(code % d) + try: + code = code.encode(getattr(self.generator, 'encoding', 'ISO8859-1')) + except AttributeError: + pass + + self.outputs[0].write(code, 'wb') self.generator.bld.raw_deps[self.uid()] = self.dep_vars = lst # make sure the signature is updated