Add a new warning gategory, ResourceWarning, as discussed on python-dev.  It is silent by default,
except when configured --with-pydebug.

Emit this warning from the GC shutdown procedure, rather than just printing to stderr.
diff --git a/Python/errors.c b/Python/errors.c
index e3486b9..0490614 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -767,8 +767,10 @@
             }
             Py_XDECREF(moduleName);
         }
-        PyFile_WriteString(" in ", f);
-        PyFile_WriteObject(obj, f, 0);
+        if (obj) {
+            PyFile_WriteString(" in ", f);
+            PyFile_WriteObject(obj, f, 0);
+        }
         PyFile_WriteString(" ignored\n", f);
         PyErr_Clear(); /* Just in case */
     }