From 356fd6e9e7677af5f691caef700ba4eda6623bfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=C3=89vrard?= Date: Mon, 29 Feb 2016 13:03:57 +0100 Subject: [PATCH] Open view and icon files in binary mode Since the support of python3 has been added file_open will return unicode object when read in normal mode but icon files has to be considered as bytes and lxml.etree.fromstring expect also bytes when there is an encoding declaration (and not unicode). issue5354 review17081002 --- trytond/ir/ui/icon.py | 2 +- trytond/ir/ui/view.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/trytond/ir/ui/icon.py b/trytond/ir/ui/icon.py index b42a16f229..2f419a358a 100644 --- a/trytond/ir/ui/icon.py +++ b/trytond/ir/ui/icon.py @@ -50,5 +50,5 @@ class Icon(ModelSQL, ModelView): def get_icon(self, name): path = os.path.join(self.module, self.path.replace('/', os.sep)) - with file_open(path, subdir='modules') as fp: + with file_open(path, subdir='modules', mode='rb') as fp: return fp.read() diff --git a/trytond/ir/ui/view.py b/trytond/ir/ui/view.py index 24cfc3ac95..0542260e2d 100644 --- a/trytond/ir/ui/view.py +++ b/trytond/ir/ui/view.py @@ -194,7 +194,7 @@ class View(ModelSQL, ModelView): if self.name and self.module: path = os.path.join(self.module, 'view', self.name + '.xml') try: - with file_open(path, subdir='modules') as fp: + with file_open(path, subdir='modules', mode='rb') as fp: value = fp.read() except IOError: pass