summaryrefslogtreecommitdiff
path: root/Modules/gcmodule.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-05-08 13:23:25 +0200
committerAntoine Pitrou <solipsis@pitrou.net>2013-05-08 13:23:25 +0200
commit63d05b117ac621279bea27b1a7903d3085d18240 (patch)
treecc776a4c3885caaf28e4233f4cdb2cf793523302 /Modules/gcmodule.c
parent79e659f5233d182dc82953a63619de619b9eda1a (diff)
downloadcpython-63d05b117ac621279bea27b1a7903d3085d18240.tar.gz
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 c9c1252d34..4315d55dcd 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)
);
}