Browse Source

Merge pull request #7058 from ThomasWaldmann/fix-memoryview-crash

avoid memoryview related TypeError in compressors
TW 2 years ago
parent
commit
1a89db0a70
1 changed files with 2 additions and 0 deletions
  1. 2 0
      src/borg/compress.pyx

+ 2 - 0
src/borg/compress.pyx

@@ -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: