Skip to content
Snippets Groups Projects
Commit 9498271d authored by Sébastien Luttringer's avatar Sébastien Luttringer
Browse files

fix python2.6 doesn"t allow keywords args for str.encode

parent 01c677ab
No related branches found
No related tags found
No related merge requests found
......@@ -803,13 +803,13 @@ class PackageImage(Image):
if gendescription:
arrow(u"Generating description file in %s" % directory)
with open(os.path.join(directory, "description"), "w") as f:
f.write((istemplate.description % self._metadata).encode('utf-8'))
f.write((istemplate.description % self._metadata).encode("UTF-8"))
# launch payload extraction
if payload:
for payname in self.payload:
# here we need to decode payname which is in unicode to escape
# tarfile to encode filename of file inside tarball inside unicode
dest = os.path.join(directory, "payload", payname.encode("utf-8"))
dest = os.path.join(directory, "payload", payname.encode("UTF-8"))
arrow(u"Extracting payload %s in %s" % (payname, dest))
self.payload[payname].extract(dest, force=force)
......
......@@ -59,7 +59,7 @@ def out(message="", fd=sys.stdout, endl=os.linesep, flush=True):
# convert unicode into str before write
# this can cause issue on python 2.6
if type(message) == unicode:
message = message.encode(locale.getpreferredencoding(), errors='replace')
message = message.encode(locale.getpreferredencoding(), "replace")
# printing
fd.write("%s%s" % (message, endl))
if flush:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment