Method
__exit__
(
self,
exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[TracebackType],
)
Source from the content-addressed store, hash-verified
| 211 | return self |
| 212 | |
| 213 | def __exit__( |
| 214 | self, |
| 215 | exc_type: Optional[Type[BaseException]], |
| 216 | exc_val: Optional[BaseException], |
| 217 | exc_tb: Optional[TracebackType], |
| 218 | ) -> None: |
| 219 | if not self._entered: |
| 220 | __tracebackhide__ = True |
| 221 | raise RuntimeError("Cannot exit %r without entering first" % self) |
| 222 | |
| 223 | super().__exit__(exc_type, exc_val, exc_tb) |
| 224 | |
| 225 | # Built-in catch_warnings does not reset entered state so we do it |
| 226 | # manually here for this context manager to become reusable. |
| 227 | self._entered = False |
| 228 | |
| 229 | |
| 230 | @final |