[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
This commit is contained in:
xmo-odoo
2018-02-02 19:39:51 +01:00
committed by GitHub
parent 63c39c7460
commit 43617bbcb6
+1 -1
View File
@@ -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()