bpo-33509: Fix _warnings for module_globals=None (#6833)

Don't crash on warnings.warn_explicit() if module_globals is not a dict.
diff --git a/Python/_warnings.c b/Python/_warnings.c
index 0568af4..29e475d 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -951,7 +951,14 @@
                 &registry, &module_globals, &sourceobj))
         return NULL;
 
-    if (module_globals) {
+    if (module_globals && module_globals != Py_None) {
+        if (!PyDict_Check(module_globals)) {
+            PyErr_Format(PyExc_TypeError,
+                         "module_globals must be a dict, not '%.200s'",
+                         Py_TYPE(module_globals)->tp_name);
+            return NULL;
+        }
+
         source_line = get_source_line(module_globals, lineno);
         if (source_line == NULL && PyErr_Occurred()) {
             return NULL;