mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
ResourceWarning: Revert change on socket and scandir
io.FileIO has a safe implementation of destructor, but not socket nor scandir.
This commit is contained in:
parent
eedf13fe23
commit
f664dc5834
2 changed files with 4 additions and 3 deletions
|
@ -12111,7 +12111,7 @@ ScandirIterator_dealloc(ScandirIterator *iterator)
|
||||||
*/
|
*/
|
||||||
++Py_REFCNT(iterator);
|
++Py_REFCNT(iterator);
|
||||||
PyErr_Fetch(&exc, &val, &tb);
|
PyErr_Fetch(&exc, &val, &tb);
|
||||||
if (PyErr_ResourceWarning((PyObject *)iterator, 1,
|
if (PyErr_WarnFormat(PyExc_ResourceWarning, 1,
|
||||||
"unclosed scandir iterator %R", iterator)) {
|
"unclosed scandir iterator %R", iterator)) {
|
||||||
/* Spurious errors can appear at shutdown */
|
/* Spurious errors can appear at shutdown */
|
||||||
if (PyErr_ExceptionMatches(PyExc_Warning))
|
if (PyErr_ExceptionMatches(PyExc_Warning))
|
||||||
|
|
|
@ -4170,7 +4170,8 @@ sock_dealloc(PySocketSockObject *s)
|
||||||
Py_ssize_t old_refcount = Py_REFCNT(s);
|
Py_ssize_t old_refcount = Py_REFCNT(s);
|
||||||
++Py_REFCNT(s);
|
++Py_REFCNT(s);
|
||||||
PyErr_Fetch(&exc, &val, &tb);
|
PyErr_Fetch(&exc, &val, &tb);
|
||||||
if (PyErr_ResourceWarning(s, 1, "unclosed %R", s))
|
if (PyErr_WarnFormat(PyExc_ResourceWarning, 1,
|
||||||
|
"unclosed %R", s))
|
||||||
/* Spurious errors can appear at shutdown */
|
/* Spurious errors can appear at shutdown */
|
||||||
if (PyErr_ExceptionMatches(PyExc_Warning))
|
if (PyErr_ExceptionMatches(PyExc_Warning))
|
||||||
PyErr_WriteUnraisable((PyObject *) s);
|
PyErr_WriteUnraisable((PyObject *) s);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue