]> granicus.if.org Git - python/commitdiff
Took Nick Coghlan's advice about importing warnings globally in logging, to avoid...
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Thu, 4 Dec 2008 20:32:18 +0000 (20:32 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Thu, 4 Dec 2008 20:32:18 +0000 (20:32 +0000)
Lib/logging/__init__.py
Misc/NEWS

index c28d7c8650d9f400cadb9455c0941a12f5fc0cc6..bd1a49d6264824364b89e57a59eaf0ea6a7fc952 100644 (file)
@@ -31,7 +31,7 @@ __all__ = ['BASIC_FORMAT', 'BufferingFormatter', 'CRITICAL', 'DEBUG', 'ERROR',
            'INFO', 'LogRecord', 'Logger', 'Manager', 'NOTSET', 'PlaceHolder',
            'RootLogger', 'StreamHandler', 'WARN', 'WARNING']
 
-import sys, os, types, time, string, cStringIO, traceback
+import sys, os, types, time, string, cStringIO, traceback, warnings
 
 try:
     import codecs
@@ -1520,7 +1520,6 @@ def _showwarning(message, category, filename, lineno, file=None, line=None):
         if _warnings_showwarning is not None:
             _warnings_showwarning(message, category, filename, lineno, file, line)
     else:
-        import warnings
         s = warnings.formatwarning(message, category, filename, lineno, line)
         logger = getLogger("py.warnings")
         if not logger.handlers:
@@ -1533,7 +1532,6 @@ def captureWarnings(capture):
     If capture is False, ensure that warnings are not redirected to logging
     but to their original destinations.
     """
-    import warnings
     global _warnings_showwarning
     if capture:
         if _warnings_showwarning is None:
index 790579554222051bfa298d7de3f0779b3be6446a..c4b020762ed60e6422a66798546449465f77880f 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -67,11 +67,11 @@ Library
   support unusual filenames (such as those containing semi-colons) in
   Content-Disposition headers.
 
-- Issue #4384: Added integration with warnings module using captureWarnings().
-  This change includes a NullHandler which does nothing; it will be of use to
-  library developers who want to avoid the "No handlers could be found for
-  logger XXX" message which can appear if the library user doesn't configure
-  logging.
+- Issue #4384: Added logging integration with warnings module using
+  captureWarnings(). This change includes a NullHandler which does nothing;
+  it will be of use to library developers who want to avoid the "No handlers
+  could be found for logger XXX" message which can appear if the library user
+  doesn't configure logging.
 
 - Issue #3741: DISTUTILS_USE_SDK set causes msvc9compiler.py to raise an
   exception.