Skip to content

Commit d7c3873

Browse files
serhiy-storchakamiss-islington
authored andcommitted
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
1 parent 5dfbb4d commit d7c3873

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Objects/moduleobject.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ module_dealloc(PyModuleObject *m)
681681

682682
PyObject_GC_UnTrack(m);
683683
if (verbose && m->md_name) {
684-
PySys_FormatStderr("# destroy %S\n", m->md_name);
684+
PySys_FormatStderr("# destroy %U\n", m->md_name);
685685
}
686686
if (m->md_weaklist != NULL)
687687
PyObject_ClearWeakRefs((PyObject *) m);
@@ -784,6 +784,12 @@ module_clear(PyModuleObject *m)
784784
{
785785
if (m->md_def && m->md_def->m_clear) {
786786
int res = m->md_def->m_clear((PyObject*)m);
787+
if (PyErr_Occurred()) {
788+
PySys_FormatStderr("Exception ignored in m_clear of module%s%V\n",
789+
m->md_name ? " " : "",
790+
m->md_name, "");
791+
PyErr_WriteUnraisable(NULL);
792+
}
787793
if (res)
788794
return res;
789795
}

0 commit comments

Comments
 (0)