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

avoid memoryview related TypeError in compressors
This commit is contained in:
TW 2022-09-28 00:52:55 +02:00 committed by GitHub
commit 1a89db0a70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -86,6 +86,8 @@ cdef class CompressorBase:
"""
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:
return None, bytes((self.ID, self.level)) + data
else: