summaryrefslogtreecommitdiffstats
path: root/Lib/logging
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2010-08-23 17:50:30 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2010-08-23 17:50:30 (GMT)
commit1ddd51fc71c6a6d255eee8e7e54d1bf7e05c5841 (patch)
treedca75879c16c1c3bdd3b730766195ec2db318220 /Lib/logging
parent9d0eaac1fcebd13a981432848d8c64627634140e (diff)
downloadcpython-1ddd51fc71c6a6d255eee8e7e54d1bf7e05c5841.zip
cpython-1ddd51fc71c6a6d255eee8e7e54d1bf7e05c5841.tar.gz
cpython-1ddd51fc71c6a6d255eee8e7e54d1bf7e05c5841.tar.bz2
Issue #9501: Fixed logging regressions in cleanup code.
Diffstat (limited to 'Lib/logging')
-rw-r--r--Lib/logging/__init__.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index 80ec672..5922ed3 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -617,12 +617,16 @@ def _removeHandlerRef(wr):
"""
Remove a handler reference from the internal cleanup list.
"""
- _acquireLock()
- try:
- if wr in _handlerList:
- _handlerList.remove(wr)
- finally:
- _releaseLock()
+ # This function can be called during module teardown, when globals are
+ # set to None. If _acquireLock is None, assume this is the case and do
+ # nothing.
+ if _acquireLock is not None:
+ _acquireLock()
+ try:
+ if wr in _handlerList:
+ _handlerList.remove(wr)
+ finally:
+ _releaseLock()
def _addHandlerRef(handler):
"""
@@ -1612,8 +1616,16 @@ def shutdown(handlerList=_handlerList):
#we just ignore them if raiseExceptions is not set
try:
h = wr()
- h.flush()
- h.close()
+ if h:
+ try:
+ h.flush()
+ h.close()
+ except (IOError, ValueError):
+ # Ignore errors which might be caused
+ # because handlers have been closed but
+ # references to them are still around at
+ # application exit.
+ pass
except:
if raiseExceptions:
raise