diff --git a/Python/_warnings.c b/Python/_warnings.c index 07fd683e53e..99f6071a0c7 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -517,6 +517,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno, } else { const char *module_str = _PyUnicode_AsString(*module); + Py_XDECREF(*filename); if (module_str == NULL) goto handle_error; if (strcmp(module_str, "__main__") == 0) {