]> granicus.if.org Git - python/commitdiff
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support...
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Sun, 7 Feb 2010 12:56:54 +0000 (12:56 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Sun, 7 Feb 2010 12:56:54 +0000 (12:56 +0000)
Lib/logging/__init__.py
Lib/logging/config.py
Misc/NEWS

index 5c727b0fe114bd56e9e6be4548668c6df1fc27fd..b5c48d34a8c3eedbd97970d12f28f1292515e041 100644 (file)
@@ -769,7 +769,10 @@ class Handler(Filterer):
         if raiseExceptions:
             ei = sys.exc_info()
             try:
-                traceback.print_exception(ei[0], ei[1], ei[2], None, sys.stderr)
+                traceback.print_exception(ei[0], ei[1], ei[2],
+                                          None, sys.stderr)
+                sys.stderr.write('Logged from file %s, line %s\n' % (
+                                 record.filename, record.lineno))
             except IOError:
                 pass    # see issue 5971
             finally:
@@ -1572,17 +1575,8 @@ def shutdown(handlerList=_handlerList):
             #else, swallow
 
 #Let's try and shutdown automatically on application exit...
-try:
-    import atexit
-    atexit.register(shutdown)
-except ImportError: # for Python versions < 2.0
-    def exithook(status, old_exit=sys.exit):
-        try:
-            shutdown()
-        finally:
-            old_exit(status)
-
-    sys.exit = exithook
+import atexit
+atexit.register(shutdown)
 
 # Null handler
 
index 1145e711903ce416ff56678121ceb759d0468b0f..fdf4397aa46fdfed1384dcf89f80a25a3a8aaaa3 100644 (file)
@@ -58,15 +58,11 @@ def fileConfig(fname, defaults=None, disable_existing_loggers=True):
     the ability to select from various pre-canned configurations (if the
     developer provides a mechanism to present the choices and load the chosen
     configuration).
-    In versions of ConfigParser which have the readfp method [typically
-    shipped in 2.x versions of Python], you can pass in a file-like object
-    rather than a filename, in which case the file-like object will be read
-    using readfp.
     """
     import ConfigParser
 
     cp = ConfigParser.ConfigParser(defaults)
-    if hasattr(cp, 'readfp') and hasattr(fname, 'readline'):
+    if hasattr(fname, 'readline'):
         cp.readfp(fname)
     else:
         cp.read(fname)
index f9f99413c01e44b2f71d96b4737eccc0d6b4b75b..68cd072ab83106691dcd393865fc70df460d62aa 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -75,6 +75,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #7869: logging: improved diagnostic for format-time errors.
+
 - Issue #7868: logging: added loggerClass attribute to Manager.
 
 - Issue #7851: logging: clarification on logging configuration files.