Kaydet (Commit) 6e8d614a authored tarafından Loic Bistuer's avatar Loic Bistuer

Made the vendored NamedTemporaryFile work as a context manager. Refs #22680.

This fixes a regression on Windows introduced by b7de5f5d.

Thanks Tim Graham for the report and review.
üst c307383e
...@@ -69,6 +69,13 @@ if os.name == 'nt': ...@@ -69,6 +69,13 @@ if os.name == 'nt':
def __del__(self): def __del__(self):
self.close() self.close()
def __enter__(self):
self.file.__enter__()
return self
def __exit__(self, exc, value, tb):
self.file.__exit__(exc, value, tb)
NamedTemporaryFile = TemporaryFile NamedTemporaryFile = TemporaryFile
else: else:
NamedTemporaryFile = tempfile.NamedTemporaryFile NamedTemporaryFile = tempfile.NamedTemporaryFile
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment