Skip to content

Commit eb60638

Browse files
committed
Update _pyio
1 parent 16d1085 commit eb60638

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

Lib/_pyio.py

+3-16
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,8 @@
3333
# Rebind for compatibility
3434
BlockingIOError = BlockingIOError
3535

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") or sys.flags.dev_mode)
3936
# Does open() check its 'errors' argument?
40-
_CHECK_ERRORS = _IOBASE_EMITS_UNRAISABLE
37+
_CHECK_ERRORS = (hasattr(sys, "gettotalrefcount") or sys.flags.dev_mode)
4138

4239

4340
def text_encoding(encoding, stacklevel=2):
@@ -416,18 +413,8 @@ def __del__(self):
416413
if closed:
417414
return
418415

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()
431418

432419
### Inquiries ###
433420

0 commit comments

Comments
 (0)