Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
sys.unraisablehook, not sys.excepthook
  • Loading branch information
vstinner committed May 31, 2023
commit 533d60da5c5d9a8b47d90c0d25860208600d20b3
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ io
--

The :class:`io.IOBase` finalizer now logs the ``close()`` method errors with
:data:`sys.excepthook`. Previously, errors were ignored silently by default,
:data:`sys.unraisablehook`. Previously, errors were ignored silently by default,
and only logged in :ref:`Python Development Mode <devmode>` or on :ref:`Python
built on debug mode <debug-build>`.
(Contributed by Victor Stinner in :gh:`62948`.)
Expand Down
3 changes: 2 additions & 1 deletion Lib/_pyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ def __del__(self):
if closed:
return

# Calling close() can fail: log an unraisable exception
# If close() fails, the caller logs the exception with
# sys.unraisablehook. close() must be called at the end at __del__().
self.close()

### Inquiries ###
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The :class:`io.IOBase` finalizer now logs the ``close()`` method errors with
:data:`sys.excepthook`. Previously, errors were ignored silently by default,
:data:`sys.unraisablehook`. Previously, errors were ignored silently by default,
and only logged in :ref:`Python Development Mode <devmode>` or on
:ref:`Python built on debug mode <debug-build>`. Patch by Victor Stinner.