summaryrefslogtreecommitdiff
path: root/addons/base_import_module/models
diff options
context:
space:
mode:
authorXavier Morel <xmo@odoo.com>2017-04-28 15:32:10 +0200
committerOlivier Dony <odo@openerp.com>2017-08-20 23:25:54 +0200
commit3824b5dcc13678d3985ad45ac21dcf9ac9202c20 (patch)
tree46502fb28fc4716c78da39a9ada868a0992fcc12 /addons/base_import_module/models
parent1b6871319d1a8b76b3e61ff258dcc4d514d40471 (diff)
[FIX] P3: fix base64 and StringIO uses
* StringIO removed from stdlib, replace with io * try to correctly handle BytesIO/StringIO (one is for bytes the other is for text) * fix base64: Python 3 removed bytes-encoding and bytes-bytes codecs (via #encode) so replace all calls to str.encode('base64'), also b64encode is a bytes->bytes conversion so attempt to properly handle that issue #8530
Diffstat (limited to 'addons/base_import_module/models')
-rw-r--r--addons/base_import_module/models/ir_module.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/addons/base_import_module/models/ir_module.py b/addons/base_import_module/models/ir_module.py
index ec94bc22d27..d6bb62a4d46 100644
--- a/addons/base_import_module/models/ir_module.py
+++ b/addons/base_import_module/models/ir_module.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+import base64
import logging
import os
import sys
@@ -63,8 +64,8 @@ class IrModule(models.Model):
for root, dirs, files in os.walk(path_static):
for static_file in files:
full_path = opj(root, static_file)
- with open(full_path, 'r') as fp:
- data = fp.read().encode('base64')
+ with open(full_path, 'rb') as fp:
+ data = base64.b64encode(fp.read())
url_path = '/%s%s' % (module, full_path.split(path)[1].replace(os.path.sep, '/'))
url_path = url_path.decode(sys.getfilesystemencoding())
filename = os.path.split(url_path)[1]