[elbe-devel] [PATCH 3/5] Python3: use encode instead of unicode() function
Christian Teklenborg
chris at linutronix.de
Fri Jan 10 15:46:00 CET 2020
Since Python3 there is no unicode() function anymore so use encode with 'utf-8'
instead of unicode().
Signed-off-by: Christian Teklenborg <chris 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 ef26c21b..3b2bf3a5 100644
--- a/elbepack/efilesystem.py
+++ b/elbepack/efilesystem.py
@@ -153,10 +153,10 @@ class ElbeFilesystem(Filesystem):
lic_text = "Error while processing license file %s: '%s'" % (
copyright_file, e.strerror)
- lic_text = unicode(lic_text, encoding='utf-8', errors='replace')
+ lic_text = lic_text.encode(encoding='utf-8', errors='replace')
if f is not None:
- f.write(unicode(pkg))
+ f.write(pkg.encode(encoding='utf-8', errors='replace'))
f.write(u":\n======================================"
"==========================================")
f.write(u"\n")
diff --git a/elbepack/licencexml.py b/elbepack/licencexml.py
index 6324fe4f..09ab3cff 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(unicode(txtnode.et.text))
+ bytesio = io.StringIO(txtnode.et.text.encode(encoding='utf-8', errors='replace'))
try:
c = Copyright(bytesio)
files = []
--
2.20.1
More information about the elbe-devel
mailing list