Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit56d73b9

Browse files
committed
gh-62948: IOBase finalizer logs close() exceptions
1 parent4b65d56 commit56d73b9

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

‎Doc/whatsnew/3.13.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ New Modules
8787
Improved Modules
8888
================
8989

90+
io
91+
--
92+
93+
The:class:`io.IOBase` finalizer now logs the ``close()`` method errors with
94+
:data:`sys.excepthook`. Previously, errors were ignored silently by default,
95+
and only logged in:ref:`Python Development Mode<devmode>` or on:ref:`Python
96+
built on debug mode <debug-build>`.
97+
(Contributed by Victor Stinner in:gh:`62948`.)
98+
9099
pathlib
91100
-------
92101

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

‎Modules/_io/iobase.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -319,20 +319,8 @@ iobase_finalize(PyObject *self)
319319
if (PyObject_SetAttr(self,&_Py_ID(_finalizing),Py_True))
320320
PyErr_Clear();
321321
res=PyObject_CallMethodNoArgs((PyObject*)self,&_Py_ID(close));
322-
/* Silencing I/O errors is bad, but printing spurious tracebacks is
323-
equally as bad, and potentially more frequent (because of
324-
shutdown issues). */
325322
if (res==NULL) {
326-
#ifndefPy_DEBUG
327-
if (_Py_GetConfig()->dev_mode) {
328-
PyErr_WriteUnraisable(self);
329-
}
330-
else {
331-
PyErr_Clear();
332-
}
333-
#else
334323
PyErr_WriteUnraisable(self);
335-
#endif
336324
}
337325
else {
338326
Py_DECREF(res);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp