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)