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 Adriane Boyd
parent 55e5f8ede3
commit a834b03216

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