diff options
author | Victor Stinner <vstinner@python.org> | 2020-01-24 17:05:24 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-24 17:05:24 (GMT) |
commit | 656c45ec9a9dc2e94cec199ebde553a6979e0e05 (patch) | |
tree | 2730a56321dcf118b231d2f08d333381832b6090 /Modules/gcmodule.c | |
parent | 88704334e5262c6cd395a0809d4ef810f33f3ca5 (diff) | |
download | cpython-656c45ec9a9dc2e94cec199ebde553a6979e0e05.zip cpython-656c45ec9a9dc2e94cec199ebde553a6979e0e05.tar.gz cpython-656c45ec9a9dc2e94cec199ebde553a6979e0e05.tar.bz2 |
bpo-38631: Avoid Py_FatalError() in GC collect() (GH-18164)
collect() should not get an exception, but it does, logging the
exception is enough. Override sys.unraisablehook to decide how to
handle unraisable exceptions.
Py_FatalError() should be avoided whenever possible.
Diffstat (limited to 'Modules/gcmodule.c')
-rw-r--r-- | Modules/gcmodule.c | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index aacdb3f..99a6c9e 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -118,9 +118,6 @@ gc_decref(PyGC_Head *g) g->_gc_prev -= 1 << _PyGC_PREV_SHIFT; } -/* Python string to use if unhandled exception occurs */ -static PyObject *gc_str = NULL; - /* set for debugging information */ #define DEBUG_STATS (1<<0) /* print collection statistics */ #define DEBUG_COLLECTABLE (1<<1) /* print collectable objects */ @@ -1310,10 +1307,7 @@ collect(PyThreadState *tstate, int generation, _PyErr_Clear(tstate); } else { - if (gc_str == NULL) - gc_str = PyUnicode_FromString("garbage collection"); - PyErr_WriteUnraisable(gc_str); - Py_FatalError("unexpected exception during garbage collection"); + _PyErr_WriteUnraisableMsg("in garbage collection", NULL); } } |