File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -609,12 +609,16 @@ def _removeHandlerRef(wr):
609609 """
610610 Remove a handler reference from the internal cleanup list.
611611 """
612- _acquireLock ()
613- try :
614- if wr in _handlerList :
615- _handlerList .remove (wr )
616- finally :
617- _releaseLock ()
612+ # This function can be called during module teardown, when globals are
613+ # set to None. If _acquireLock is None, assume this is the case and do
614+ # nothing.
615+ if _acquireLock is not None :
616+ _acquireLock ()
617+ try :
618+ if wr in _handlerList :
619+ _handlerList .remove (wr )
620+ finally :
621+ _releaseLock ()
618622
619623def _addHandlerRef (handler ):
620624 """
@@ -1604,8 +1608,16 @@ def shutdown(handlerList=_handlerList):
16041608 #we just ignore them if raiseExceptions is not set
16051609 try :
16061610 h = wr ()
1607- h .flush ()
1608- h .close ()
1611+ if h :
1612+ try :
1613+ h .flush ()
1614+ h .close ()
1615+ except (IOError , ValueError ):
1616+ # Ignore errors which might be caused
1617+ # because handlers have been closed but
1618+ # references to them are still around at
1619+ # application exit.
1620+ pass
16091621 except :
16101622 if raiseExceptions :
16111623 raise
Original file line number Diff line number Diff line change @@ -123,6 +123,8 @@ Extensions
123123Library
124124-------
125125
126+ - Issue #9501: Fixed logging regressions in cleanup code.
127+
126128- Fix functools.total_ordering() to actually work.
127129
128130- Issue #9572: Importlib should not raise an exception if a directory it
You can’t perform that action at this time.
0 commit comments