[elbe-devel] [PATCH] Revert "Python3: use encode instead of unicode() function"
Torben Hohn
torben.hohn at linutronix.de
Fri Jan 31 13:05:02 CET 2020
This reverts commit 91b938d2491d2ae680b2165ec54fc73594bed874.
The "python3 fix" generates an Error on python2:
--------------------------------------------------------------------------------------
Traceback (most recent call last):
File "/var/cache/elbe/devel/elbepack/asyncworker.py", line 186, in execute
skip_pbuild=self.skip_pbuilder)
File "/var/cache/elbe/devel/elbepack/elbeproject.py", line 585, in build
self.buildenv.rfs.write_licenses(f, pkgnames, lic_xml_fname)
File "/var/cache/elbe/devel/elbepack/efilesystem.py", line 161, in
f.write(pkg.encode(encoding='utf-8', errors='replace'))
TypeError: write() argument 1 must be unicode, not str
--------------------------------------------------------------------------------------
This code only runs inside the initvm an does not need to be ported to
python3 immediately.
Revert until a proper resolution is found.
Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
elbepack/efilesystem.py | 4 ++--
elbepack/licencexml.py | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/elbepack/efilesystem.py b/elbepack/efilesystem.py
index 050a95d95..5bc20afda 100644
--- a/elbepack/efilesystem.py
+++ b/elbepack/efilesystem.py
@@ -155,10 +155,10 @@ class ElbeFilesystem(Filesystem):
lic_text = "Error while processing license file %s: '%s'" % (
copyright_file, e.strerror)
- lic_text = lic_text.encode(encoding='utf-8', errors='replace')
+ lic_text = unicode(lic_text, encoding='utf-8', errors='replace')
if f is not None:
- f.write(pkg.encode(encoding='utf-8', errors='replace'))
+ f.write(unicode(pkg))
f.write(u":\n======================================"
"==========================================")
f.write(u"\n")
diff --git a/elbepack/licencexml.py b/elbepack/licencexml.py
index 09ab3cff7..6324fe4f9 100644
--- a/elbepack/licencexml.py
+++ b/elbepack/licencexml.py
@@ -60,7 +60,7 @@ class copyright_xml (object):
txtnode = xmlpkg.append('text')
txtnode.et.text = copyright_text
- bytesio = io.StringIO(txtnode.et.text.encode(encoding='utf-8', errors='replace'))
+ bytesio = io.StringIO(unicode(txtnode.et.text))
try:
c = Copyright(bytesio)
files = []
--
2.20.1
More information about the elbe-devel
mailing list