diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-10-08 10:46:17 (GMT) |
---|---|---|
committer | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-10-08 10:46:17 (GMT) |
commit | d7c387384a27f37e4e3fa7890c859212c56b45b2 (patch) | |
tree | 3c6ab29c9c223cff416aa50af1fe75b397053244 /Objects | |
parent | 5dfbb4d50333e7a91fc0cd8c03a2f2f2cf56dbd9 (diff) | |
download | cpython-d7c387384a27f37e4e3fa7890c859212c56b45b2.zip cpython-d7c387384a27f37e4e3fa7890c859212c56b45b2.tar.gz cpython-d7c387384a27f37e4e3fa7890c859212c56b45b2.tar.bz2 |
bpo-33714: Output an exception raised in module's m_clear(). (GH-16592)
It is similar to the more general code in the gc module, but
here we know the name of the module.
https://bugs.python.org/issue33714
Automerge-Triggered-By: @encukou
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/moduleobject.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c index 92f97e6..03c7381 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -681,7 +681,7 @@ module_dealloc(PyModuleObject *m) PyObject_GC_UnTrack(m); if (verbose && m->md_name) { - PySys_FormatStderr("# destroy %S\n", m->md_name); + PySys_FormatStderr("# destroy %U\n", m->md_name); } if (m->md_weaklist != NULL) PyObject_ClearWeakRefs((PyObject *) m); @@ -784,6 +784,12 @@ module_clear(PyModuleObject *m) { if (m->md_def && m->md_def->m_clear) { int res = m->md_def->m_clear((PyObject*)m); + if (PyErr_Occurred()) { + PySys_FormatStderr("Exception ignored in m_clear of module%s%V\n", + m->md_name ? " " : "", + m->md_name, ""); + PyErr_WriteUnraisable(NULL); + } if (res) return res; } |