From c771f0faeaf7e245166b8b9a40ba5da4d5e52296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 5 Jul 2016 22:00:57 +0200 Subject: [PATCH] Force encoding to open XML files The views and icons file should always be encoded in UTF-8, so it is better to force it when opening than relying on the default system. issue5596 review21101002 --- trytond/ir/ui/icon.py | 3 ++- trytond/ir/ui/view.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/trytond/ir/ui/icon.py b/trytond/ir/ui/icon.py index 14877d8cbc..31f148484e 100644 --- a/trytond/ir/ui/icon.py +++ b/trytond/ir/ui/icon.py @@ -50,5 +50,6 @@ 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', mode='r') as fp: + with file_open(path, + subdir='modules', mode='r', encoding='utf-8') as fp: return fp.read() diff --git a/trytond/ir/ui/view.py b/trytond/ir/ui/view.py index d03dc6a1ce..33a4b7070b 100644 --- a/trytond/ir/ui/view.py +++ b/trytond/ir/ui/view.py @@ -193,7 +193,8 @@ 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', mode='r') as fp: + with file_open(path, + subdir='modules', mode='r', encoding='utf-8') as fp: value = fp.read() except IOError: pass