(self, f)
| 454 | _file = None |
| 455 | |
| 456 | def __init__(self, f): |
| 457 | self._i_opened_the_file = None |
| 458 | if isinstance(f, (bytes, str, os.PathLike)): |
| 459 | f = builtins.open(f, 'wb') |
| 460 | self._i_opened_the_file = f |
| 461 | try: |
| 462 | self.initfp(f) |
| 463 | except: |
| 464 | if self._i_opened_the_file: |
| 465 | f.close() |
| 466 | raise |
| 467 | |
| 468 | def initfp(self, file): |
| 469 | self._file = file |