[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:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user