From 43617bbcb65fc4048ad97567067cb2f3138873a3 Mon Sep 17 00:00:00 2001 From: xmo-odoo Date: Fri, 2 Feb 2018 19:39:51 +0100 Subject: [PATCH] [FIX] type error when exporting to tarfiles When exporting to a tarfile, we first export each module's translations to a file on the FS, then create a tarball from all of them. With the P3 bytes/string split, translation export was defined to export to a bytes IO object in order to work correctly with CSV (which work on bytes IO for better cross-version compatibility). However the tgz file export was left opening module's files in `w` mode, which in P3 means text, which blows up as POFile expects to ultimately write to a bytes IO object: it uses text, and a StreamReaderWriter is used to translate that into an underlying bytes IO. Fix by explicitly opening the files in binary mode. Fixes #22700 --- odoo/tools/translate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/tools/translate.py b/odoo/tools/translate.py index 714d0734f56..92a46e794f6 100644 --- a/odoo/tools/translate.py +++ b/odoo/tools/translate.py @@ -696,7 +696,7 @@ def trans_export(lang, modules, buffer, format, cr): tmpmoddir = join(tmpdir, mod, 'i18n') os.makedirs(tmpmoddir) pofilename = (lang if lang else mod) + ".po" + ('t' if not lang else '') - buf = open(join(tmpmoddir, pofilename), 'w') + buf = open(join(tmpmoddir, pofilename), 'wb') _process('po', [mod], modrows, buf, lang) buf.close()