]> granicus.if.org Git - python/commitdiff
Issue 5013: Fixed bug in FileHandler when delay was set.
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Tue, 20 Jan 2009 22:43:17 +0000 (22:43 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Tue, 20 Jan 2009 22:43:17 +0000 (22:43 +0000)
Lib/logging/__init__.py
Misc/NEWS

index c77cde3955ffdfd48bf23f2a17ad83befbb1a061..d61c0f1522272a5d304016677b497846d1fa03d4 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2001-2008 by Vinay Sajip. All Rights Reserved.
+# Copyright 2001-2009 by Vinay Sajip. All Rights Reserved.
 #
 # Permission to use, copy, modify, and distribute this software and its
 # documentation for any purpose and without fee is hereby granted,
@@ -21,7 +21,7 @@ comp.lang.python, and influenced by Apache's log4j system.
 Should work under Python versions >= 1.5.2, except that source line
 information is not available unless 'sys._getframe()' is.
 
-Copyright (C) 2001-2008 Vinay Sajip. All Rights Reserved.
+Copyright (C) 2001-2009 Vinay Sajip. All Rights Reserved.
 
 To use, simply 'import logging' and log away!
 """
@@ -46,8 +46,8 @@ except ImportError:
 
 __author__  = "Vinay Sajip <vinay_sajip@red-dove.com>"
 __status__  = "production"
-__version__ = "0.5.0.6"
-__date__    = "03 December 2008"
+__version__ = "0.5.0.7"
+__date__    = "20 January 2009"
 
 #---------------------------------------------------------------------------
 #   Miscellaneous module data
@@ -740,7 +740,6 @@ class StreamHandler(Handler):
         if strm is None:
             strm = sys.stderr
         self.stream = strm
-        self.formatter = None
 
     def flush(self):
         """
@@ -795,10 +794,12 @@ class FileHandler(StreamHandler):
         self.mode = mode
         self.encoding = encoding
         if delay:
+            #We don't open the stream, but we still need to call the
+            #Handler constructor to set level, formatter, lock etc.
+            Handler.__init__(self)
             self.stream = None
         else:
-            stream = self._open()
-            StreamHandler.__init__(self, stream)
+            StreamHandler.__init__(self, self._open())
 
     def close(self):
         """
@@ -830,8 +831,7 @@ class FileHandler(StreamHandler):
         constructor, open it before calling the superclass's emit.
         """
         if self.stream is None:
-            stream = self._open()
-            StreamHandler.__init__(self, stream)
+            self.stream = self._open()
         StreamHandler.emit(self, record)
 
 #---------------------------------------------------------------------------
index 9d234bdc2f748bd4842f348711345ce4e228af50..a3f0242ca9b6d086b5f070a352ad5cdddd719189 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -145,6 +145,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #5013: Fixed a bug in FileHandler which occurred when the delay
+  parameter was set.
+
 - Issue #4998: The memory saving effect of __slots__ had been lost on Fractions
   which inherited from numbers.py which did not have __slots__ defined.  The
   numbers heirarchy now has its own __slots__ declarations.
@@ -177,7 +180,7 @@ Library
 
 - Restore Python 2.3 compatibility for decimal.py.
 
-- Issue #1702551: distutils sdist was not excluding VCS directories under 
+- Issue #1702551: distutils sdist was not excluding VCS directories under
   Windows. Inital solution by Guy Dalberto.
 
 - The _tkinter module functions "createfilehandler", "deletefilehandler",
@@ -193,10 +196,10 @@ Library
 - Issue #4795: inspect.isgeneratorfunction() returns False instead of None when
   the function is not a generator.
 
-- Issue #4702: Throwing a DistutilsPlatformError instead of IOError in case 
-  no MSVC compiler is found under Windows. Original patch by Philip Jenvey. 
+- Issue #4702: Throwing a DistutilsPlatformError instead of IOError in case
+  no MSVC compiler is found under Windows. Original patch by Philip Jenvey.
 
-- Issue #4646: distutils was choking on empty options arg in the setup 
+- Issue #4646: distutils was choking on empty options arg in the setup
   function. Original patch by Thomas Heller.
 
 - Fractions.from_float() no longer loses precision for integers too big to
@@ -318,7 +321,7 @@ Library
   to be consistent with Apple tools.
 
 - Issue #900949: plat-mac/videoreader.py no longer relies on a non-existing
-  module. 
+  module.
 
 - Issue #16278952: plat-mac/videoreader.py now correctly imports MediaDescr
 
@@ -375,7 +378,7 @@ C-API
 
 - Issue #4122: On Windows, fix a compilation error when using the
   Py_UNICODE_ISSPACE macro in an extension module.
-  
+
 - Issue #4293: Py_AddPendingCall is now thread safe and can be used for
   asynchronous notifications to python from any thread.  Documentation added.