Support for the context manager protocol. Close the file if no exceptions occur and allow exceptions to propagate.
(self, exc_type: Any, exc_val: Any, exc_tb: Any)
| 1420 | return self |
| 1421 | |
| 1422 | def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> Any: |
| 1423 | """Support for the context manager protocol. |
| 1424 | |
| 1425 | Close the file if no exceptions occur and allow exceptions to propagate. |
| 1426 | """ |
| 1427 | if exc_type is None: |
| 1428 | # No exceptions happened. |
| 1429 | self.close() |
| 1430 | else: |
| 1431 | # Something happened, at minimum mark as closed. |
| 1432 | object.__setattr__(self, "_closed", True) |
| 1433 | |
| 1434 | # propagate exceptions |
| 1435 | return False |
| 1436 | |
| 1437 | |
| 1438 | GRIDOUT_BASE_CLASS = io.IOBase if _IS_SYNC else object # type: Any |
nothing calls this directly
no test coverage detected