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
This commit is contained in:
Nicolas Évrard committed 2016-02-29 13:03:57 +01:00
1 parent 64d6e4b3ec
commit 356fd6e9e7
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -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()
+1 -1
View File
@@ -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