|
33 | 33 | # Rebind for compatibility
|
34 | 34 | BlockingIOError=BlockingIOError
|
35 | 35 |
|
36 |
| -# Does io.IOBase finalizer log the exception if the close() method fails? |
37 |
| -# The exception is ignored silently by default in release build. |
38 |
| -_IOBASE_EMITS_UNRAISABLE= (hasattr(sys,"gettotalrefcount")orsys.flags.dev_mode) |
39 | 36 | # Does open() check its 'errors' argument?
|
40 |
| -_CHECK_ERRORS=_IOBASE_EMITS_UNRAISABLE |
| 37 | +_CHECK_ERRORS=(hasattr(sys,"gettotalrefcount")orsys.flags.dev_mode) |
41 | 38 |
|
42 | 39 |
|
43 | 40 | deftext_encoding(encoding,stacklevel=2):
|
@@ -416,18 +413,8 @@ def __del__(self):
|
416 | 413 | ifclosed:
|
417 | 414 | return
|
418 | 415 |
|
419 |
| -if_IOBASE_EMITS_UNRAISABLE: |
420 |
| -self.close() |
421 |
| -else: |
422 |
| -# The try/except block is in case this is called at program |
423 |
| -# exit time, when it's possible that globals have already been |
424 |
| -# deleted, and then the close() call might fail. Since |
425 |
| -# there's nothing we can do about such failures and they annoy |
426 |
| -# the end users, we suppress the traceback. |
427 |
| -try: |
428 |
| -self.close() |
429 |
| -except: |
430 |
| -pass |
| 416 | +# Calling close() can fail: log an unraisable exception |
| 417 | +self.close() |
431 | 418 |
|
432 | 419 | ### Inquiries ###
|
433 | 420 |
|
|