]> granicus.if.org Git - python/commitdiff
bpo-33714: Output an exception raised in module's m_clear(). (GH-16592)
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 8 Oct 2019 10:46:17 +0000 (13:46 +0300)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 8 Oct 2019 10:46:17 +0000 (03:46 -0700)
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
Objects/moduleobject.c

index 92f97e6dd48502da941c818c9a939384d4df7103..03c7381311aa14bbc253ac0e92f96d454f0d27c5 100644 (file)
@@ -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;
     }