Skip to content

Commit 533d60d

Browse files
committed
sys.unraisablehook, not sys.excepthook
1 parent b840a37 commit 533d60d

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

Doc/whatsnew/3.13.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ io
9191
--
9292

9393
The :class:`io.IOBase` finalizer now logs the ``close()`` method errors with
94-
:data:`sys.excepthook`. Previously, errors were ignored silently by default,
94+
:data:`sys.unraisablehook`. Previously, errors were ignored silently by default,
9595
and only logged in :ref:`Python Development Mode <devmode>` or on :ref:`Python
9696
built on debug mode <debug-build>`.
9797
(Contributed by Victor Stinner in :gh:`62948`.)

Lib/_pyio.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ def __del__(self):
413413
if closed:
414414
return
415415

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

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

0 commit comments

Comments
 (0)