]> granicus.if.org Git - python/commitdiff
ResourceWarning: Revert change on socket and scandir
authorVictor Stinner <victor.stinner@gmail.com>
Sat, 19 Mar 2016 01:01:48 +0000 (02:01 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Sat, 19 Mar 2016 01:01:48 +0000 (02:01 +0100)
io.FileIO has a safe implementation of destructor, but not socket nor scandir.

Modules/posixmodule.c
Modules/socketmodule.c

index 3f22d14ffbb18ec335782d383b081d471440d6ac..65b20be4686e666794ec486e1d34bd758e43850f 100644 (file)
@@ -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);
index 657b04b7a6c63440d810420d9873e904b271c85f..77a6b313b0321986c96af89dfd05218e8b1aa0ff 100644 (file)
@@ -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);