XML files must be open in binary mode for sax parser

The sax parser expect a byte stream, so we must open the file with the binary
mode. Also file_open should have a default encoding to None because encoding
should not be set in binary mode.

issue5313
This commit is contained in:
Cédric Krier committed 2016-02-09 22:45:44 +01:00
1 parent 7ca5529e49
commit 70827fe06b
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -244,7 +244,7 @@ def load_module_graph(graph, pool, update=None, lang=None):
filename = filename.replace('/', os.sep)
logger.info('%s:loading %s', module, filename)
# Feed the parser with xml content:
with tools.file_open(OPJ(module, filename)) as fp:
with tools.file_open(OPJ(module, filename), 'rb') as fp:
tryton_parser.parse_xmlstream(fp)
modules_todo.append((module, list(tryton_parser.to_delete)))
+1 -1
View File
@@ -51,7 +51,7 @@ def exec_command_pipe(name, *args, **kwargs):
stdout=subprocess.PIPE, env=child_env)
def file_open(name, mode="r", subdir='modules', encoding='utf-8'):
def file_open(name, mode="r", subdir='modules', encoding=None):
"""Open a file from the root dir, using a subdir folder."""
from trytond.modules import EGG_MODULES
if sys.version_info < (3,):