Skip to content

Commit cd7161a

Browse files
authored
Merge pull request #11 from smartfile/python3
Check if data is already bytes
2 parents 59030cb + c9f15fe commit cd7161a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

libarchive/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,10 @@ def write(self, member, data=None):
550550

551551
if data:
552552
if PY3:
553-
result = _libarchive.archive_write_data_from_str(self._a, data.encode('utf8'))
553+
if isinstance(data, bytes):
554+
result = _libarchive.archive_write_data_from_str(self._a, data)
555+
else:
556+
result = _libarchive.archive_write_data_from_str(self._a, data.encode('utf8'))
554557
else:
555558
result = _libarchive.archive_write_data_from_str(self._a, data)
556559
_libarchive.archive_write_finish_entry(self._a)

0 commit comments

Comments
 (0)