Skip to content

Commit

Permalink
Update _pyio
Browse files Browse the repository at this point in the history
  • Loading branch information
vstinner committed May 30, 2023
1 parent 16d1085 commit eb60638
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions Lib/_pyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@
# Rebind for compatibility
BlockingIOError = BlockingIOError

# Does io.IOBase finalizer log the exception if the close() method fails?
# The exception is ignored silently by default in release build.
_IOBASE_EMITS_UNRAISABLE = (hasattr(sys, "gettotalrefcount") or sys.flags.dev_mode)
# Does open() check its 'errors' argument?
_CHECK_ERRORS = _IOBASE_EMITS_UNRAISABLE
_CHECK_ERRORS = (hasattr(sys, "gettotalrefcount") or sys.flags.dev_mode)


def text_encoding(encoding, stacklevel=2):
Expand Down Expand Up @@ -416,18 +413,8 @@ def __del__(self):
if closed:
return

if _IOBASE_EMITS_UNRAISABLE:
self.close()
else:
# The try/except block is in case this is called at program
# exit time, when it's possible that globals have already been
# deleted, and then the close() call might fail. Since
# there's nothing we can do about such failures and they annoy
# the end users, we suppress the traceback.
try:
self.close()
except:
pass
# Calling close() can fail: log an unraisable exception
self.close()

### Inquiries ###

Expand Down

0 comments on commit eb60638

Please sign in to comment.