diff --git a/libarchive/__init__.py b/libarchive/__init__.py index 8cd8f95..7fd44b6 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -550,7 +550,10 @@ class Archive(object): if data: if PY3: - result = _libarchive.archive_write_data_from_str(self._a, data.encode('utf8')) + if isinstance(data, bytes): + result = _libarchive.archive_write_data_from_str(self._a, data) + else: + result = _libarchive.archive_write_data_from_str(self._a, data.encode('utf8')) else: result = _libarchive.archive_write_data_from_str(self._a, data) _libarchive.archive_write_finish_entry(self._a)