Destructor. Calls close().
(self)
| 421 | self.__closed = True |
| 422 | |
| 423 | def __del__(self): |
| 424 | """Destructor. Calls close().""" |
| 425 | try: |
| 426 | closed = self.closed |
| 427 | except AttributeError: |
| 428 | # If getting closed fails, then the object is probably |
| 429 | # in an unusable state, so ignore. |
| 430 | return |
| 431 | |
| 432 | if closed: |
| 433 | return |
| 434 | |
| 435 | if _IOBASE_EMITS_UNRAISABLE: |
| 436 | self.close() |
| 437 | else: |
| 438 | # The try/except block is in case this is called at program |
| 439 | # exit time, when it's possible that globals have already been |
| 440 | # deleted, and then the close() call might fail. Since |
| 441 | # there's nothing we can do about such failures and they annoy |
| 442 | # the end users, we suppress the traceback. |
| 443 | try: |
| 444 | self.close() |
| 445 | except: |
| 446 | pass |
| 447 | |
| 448 | ### Inquiries ### |
| 449 |