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

Lib/warnings.py
Misc/NEWS

index 5eac60f7c5b934d8cc634d8945c328d0daf3775f..8baac479cd2be83e432d8a3017a360e8b69cd097 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 6729ea8a7944da2813e4ea062d077f0c2b49c8e4..a95774fcec91040c91c3244b5aa656eb6a770c98 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -335,6 +335,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 #1177307: Added a new codec utf_8_sig for UTF-8 with a BOM signature.
 
 - Patch #1157027: cookielib mishandles RFC 2109 cookies in Netscape mode