1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-02-26 07:53:58 +00:00

avoid memoryview related TypeError in compressors

fixes:

https://github.com/borgbackup/borg/discussions/7020#discussioncomment-3741024
This commit is contained in:
Thomas Waldmann 2022-09-27 23:41:21 +02:00
parent 58c375678a
commit 515833c664

View file

@ -86,6 +86,8 @@ cdef class CompressorBase:
""" """
Compress *data* (bytes) and return compression metadata and compressed bytes. Compress *data* (bytes) and return compression metadata and compressed bytes.
""" """
if not isinstance(data, bytes):
data = bytes(data) # code below does not work with memoryview
if self.legacy_mode: if self.legacy_mode:
return None, bytes((self.ID, self.level)) + data return None, bytes((self.ID, self.level)) + data
else: else: