summaryrefslogtreecommitdiffstats
path: root/Modules/gcmodule.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-05-08 11:23:25 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2013-05-08 11:23:25 (GMT)
commit070cb3c9bed3fbdbda42c257e05d46adcbeb784e (patch)
tree747b3c3a8e2fd7ecdfb5123bcb425e47ba5913b2 /Modules/gcmodule.c
parentd62a5143867096e1eeeca82b8db229dd27e94569 (diff)
downloadcpython-070cb3c9bed3fbdbda42c257e05d46adcbeb784e.zip
cpython-070cb3c9bed3fbdbda42c257e05d46adcbeb784e.tar.gz
cpython-070cb3c9bed3fbdbda42c257e05d46adcbeb784e.tar.bz2
Issue #1545463: At shutdown, defer finalization of codec modules so that stderr remains usable.
(should fix Windows buildbot failures on test_gc)
Diffstat (limited to 'Modules/gcmodule.c')
-rw-r--r--Modules/gcmodule.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index c9c1252..4315d55 100644
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -1557,8 +1557,12 @@ _PyGC_DumpShutdownStats(void)
else
message = "gc: %zd uncollectable objects at " \
"shutdown; use gc.set_debug(gc.DEBUG_UNCOLLECTABLE) to list them";
- if (PyErr_WarnFormat(PyExc_ResourceWarning, 0, message,
- PyList_GET_SIZE(garbage)) < 0)
+ /* PyErr_WarnFormat does too many things and we are at shutdown,
+ the warnings module's dependencies (e.g. linecache) may be gone
+ already. */
+ if (PyErr_WarnExplicitFormat(PyExc_ResourceWarning, "gc", 0,
+ "gc", NULL, message,
+ PyList_GET_SIZE(garbage)))
PyErr_WriteUnraisable(NULL);
if (debug & DEBUG_UNCOLLECTABLE) {
PyObject *repr = NULL, *bytes = NULL;
@@ -1567,7 +1571,7 @@ _PyGC_DumpShutdownStats(void)
PyErr_WriteUnraisable(garbage);
else {
PySys_WriteStderr(
- " %s\n",
+ " %s\n",
PyBytes_AS_STRING(bytes)
);
}