]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Bug #1403410: The warnings module now doesn't get confused
authorGeorg Brandl <georg@python.org>
Fri, 13 Jan 2006 16:59:54 +0000 (16:59 +0000)
committerGeorg Brandl <georg@python.org>
Fri, 13 Jan 2006 16:59:54 +0000 (16:59 +0000)
when it can't find out the module name it generates a warning for.

Lib/warnings.py
Misc/NEWS

index 8d8c36d890109664e8800d0c66e07cee64606d7c..fc49ca0b5dbeb3e0e9cc849be767b09bd77cde13 100644 (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:
index 30591b51fa7ed26b6a3503f14225311396716be8..ca9317163a215734b54d7a7bb4985507d310abce 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -68,6 +68,9 @@ Extension Modules
 Library
 -------
 
+- Bug #1403410: The warnings module now doesn't get confused
+  when it can't find out the module name it generates a warning for.
+  
 - Patch #1117398: cookielib.LWPCookieJar and .MozillaCookieJar now raise
   LoadError as documented, instead of IOError.  For compatibility,
   LoadError subclasses IOError.