diff options
Diffstat (limited to 'Python')
-rw-r--r-- | Python/_warnings.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c index 0568af4df5..29e475d67d 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -951,7 +951,14 @@ warnings_warn_explicit(PyObject *self, PyObject *args, PyObject *kwds) ®istry, &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; |