If PdfParser buffer is memoryview, release it when closing (#9596)
This commit is contained in:
commit
b656f900b4
@ -383,7 +383,7 @@ class PdfParser:
|
||||
msg = "specify buf or f or filename, but not both buf and f"
|
||||
raise RuntimeError(msg)
|
||||
self.filename = filename
|
||||
self.buf: bytes | bytearray | mmap.mmap | None = buf
|
||||
self.buf: bytes | bytearray | memoryview | mmap.mmap | None = buf
|
||||
self.f = f
|
||||
self.start_offset = start_offset
|
||||
self.should_close_buf = False
|
||||
@ -435,7 +435,9 @@ class PdfParser:
|
||||
self.seek_end()
|
||||
|
||||
def close_buf(self) -> None:
|
||||
if isinstance(self.buf, mmap.mmap):
|
||||
if isinstance(self.buf, memoryview):
|
||||
self.buf.release()
|
||||
elif isinstance(self.buf, mmap.mmap):
|
||||
self.buf.close()
|
||||
self.buf = None
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user