Bug #1403410: The warnings module now doesn't get confused

when it can't find out the module name it generates a warning for.
This commit is contained in:
Georg Brandl 2006-01-13 16:59:46 +00:00
parent a28ad77844
commit 4edd989eaf
2 changed files with 4 additions and 1 deletions

View file

@ -63,7 +63,7 @@ def warn(message, category=None, stacklevel=1):
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: