Bug #1403410: The warnings module now doesn't get confused
when it can't find out the module name it generates a warning for.
diff --git a/Lib/warnings.py b/Lib/warnings.py
index 5eac60f..8baac47 100644
--- a/Lib/warnings.py
+++ b/Lib/warnings.py
@@ -63,7 +63,7 @@
def warn_explicit(message, category, filename, lineno,
module=None, registry=None):
if module is None:
- module = filename
+ module = filename or "<unknown>"
if module[-3:].lower() == ".py":
module = module[:-3] # XXX What about leading pathname?
if registry is None: