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 # Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted, # 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 Should work under Python versions >= 1.5.2, except that source line
information is not available unless 'sys._getframe()' is. 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! To use, simply 'import logging' and log away!
""" """
@ -46,8 +46,8 @@ except ImportError:
__author__ = "Vinay Sajip <vinay_sajip@red-dove.com>" __author__ = "Vinay Sajip <vinay_sajip@red-dove.com>"
__status__ = "production" __status__ = "production"
__version__ = "0.5.0.6" __version__ = "0.5.0.7"
__date__ = "03 December 2008" __date__ = "20 January 2009"
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Miscellaneous module data # Miscellaneous module data
@ -740,7 +740,6 @@ class StreamHandler(Handler):
if strm is None: if strm is None:
strm = sys.stderr strm = sys.stderr
self.stream = strm self.stream = strm
self.formatter = None
def flush(self): def flush(self):
""" """
@ -795,10 +794,12 @@ class FileHandler(StreamHandler):
self.mode = mode self.mode = mode
self.encoding = encoding self.encoding = encoding
if delay: 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 self.stream = None
else: else:
stream = self._open() StreamHandler.__init__(self, self._open())
StreamHandler.__init__(self, stream)
def close(self): def close(self):
""" """
@ -830,8 +831,7 @@ class FileHandler(StreamHandler):
constructor, open it before calling the superclass's emit. constructor, open it before calling the superclass's emit.
""" """
if self.stream is None: if self.stream is None:
stream = self._open() self.stream = self._open()
StreamHandler.__init__(self, stream)
StreamHandler.emit(self, record) StreamHandler.emit(self, record)
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------

View File

@ -145,6 +145,9 @@ Core and Builtins
Library 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 - 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 which inherited from numbers.py which did not have __slots__ defined. The
numbers heirarchy now has its own __slots__ declarations. numbers heirarchy now has its own __slots__ declarations.
@ -177,7 +180,7 @@ Library
- Restore Python 2.3 compatibility for decimal.py. - 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. Windows. Inital solution by Guy Dalberto.
- The _tkinter module functions "createfilehandler", "deletefilehandler", - The _tkinter module functions "createfilehandler", "deletefilehandler",
@ -193,10 +196,10 @@ Library
- Issue #4795: inspect.isgeneratorfunction() returns False instead of None when - Issue #4795: inspect.isgeneratorfunction() returns False instead of None when
the function is not a generator. the function is not a generator.
- Issue #4702: Throwing a DistutilsPlatformError instead of IOError in case - Issue #4702: Throwing a DistutilsPlatformError instead of IOError in case
no MSVC compiler is found under Windows. Original patch by Philip Jenvey. 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. function. Original patch by Thomas Heller.
- Fractions.from_float() no longer loses precision for integers too big to - Fractions.from_float() no longer loses precision for integers too big to
@ -318,7 +321,7 @@ Library
to be consistent with Apple tools. to be consistent with Apple tools.
- Issue #900949: plat-mac/videoreader.py no longer relies on a non-existing - 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 - 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 - Issue #4122: On Windows, fix a compilation error when using the
Py_UNICODE_ISSPACE macro in an extension module. Py_UNICODE_ISSPACE macro in an extension module.
- Issue #4293: Py_AddPendingCall is now thread safe and can be used for - Issue #4293: Py_AddPendingCall is now thread safe and can be used for
asynchronous notifications to python from any thread. Documentation added. asynchronous notifications to python from any thread. Documentation added.