Issue 5013: Fixed bug in FileHandler when delay was set.

This commit is contained in:
Vinay Sajip 2009-01-20 22:43:17 +00:00
parent 933d3a7a54
commit 5fb11b2b85
2 changed files with 18 additions and 15 deletions

View 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)
#---------------------------------------------------------------------------

View File

@ -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.