Use a context manager when reading model (fix #7036) (#8244)

This commit is contained in:
Paul O'Leary McCann 2021-05-31 16:36:17 +09:00 committed by GitHub
parent cd6bd91c3a
commit 04239e94c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -324,7 +324,8 @@ cdef class TrainablePipe(Pipe):
def load_model(p):
try:
self.model.from_bytes(p.open("rb").read())
with open(p, "rb") as mfile:
self.model.from_bytes(mfile.read())
except AttributeError:
raise ValueError(Errors.E149) from None