From: Victor Stinner Date: Sat, 19 Mar 2016 01:01:48 +0000 (+0100) Subject: ResourceWarning: Revert change on socket and scandir X-Git-Tag: v3.6.0a1~436 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f664dc58344fc615f8f5649752bf5cb54efe5b3b;p=thirdparty%2FPython%2Fcpython.git ResourceWarning: Revert change on socket and scandir io.FileIO has a safe implementation of destructor, but not socket nor scandir. --- diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 3f22d14ffbb1..65b20be4686e 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -12111,8 +12111,8 @@ ScandirIterator_dealloc(ScandirIterator *iterator) */ ++Py_REFCNT(iterator); PyErr_Fetch(&exc, &val, &tb); - if (PyErr_ResourceWarning((PyObject *)iterator, 1, - "unclosed scandir iterator %R", iterator)) { + if (PyErr_WarnFormat(PyExc_ResourceWarning, 1, + "unclosed scandir iterator %R", iterator)) { /* Spurious errors can appear at shutdown */ if (PyErr_ExceptionMatches(PyExc_Warning)) PyErr_WriteUnraisable((PyObject *) iterator); diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 657b04b7a6c6..77a6b313b032 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -4170,7 +4170,8 @@ sock_dealloc(PySocketSockObject *s) Py_ssize_t old_refcount = Py_REFCNT(s); ++Py_REFCNT(s); 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 */ if (PyErr_ExceptionMatches(PyExc_Warning)) PyErr_WriteUnraisable((PyObject *) s);