From 2f7a7d674fe0a2cfa92da8ca00037032b4c7b61b Mon Sep 17 00:00:00 2001 From: Vadim Lebedev Date: Mon, 8 Aug 2022 20:03:44 +0200 Subject: [PATCH] More Python 2 compatibility fixes --- libarchive/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libarchive/__init__.py b/libarchive/__init__.py index 0efde21..038fe81 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -285,7 +285,10 @@ class EntryWriteStream(object): if self.closed: raise Exception('Cannot write to closed stream.') if self.buffer: - self.buffer.write(data) + if PY3: + self.buffer.write(data) + else: + self.buffer.write(data.encode('utf-8')) else: _libarchive.archive_write_data_from_str(self.archive._a, data.encode('utf-8')) self.bytes += len(data)