diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 6791259f8e6..ba40067b613 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -702,8 +702,10 @@ class Handler(Filterer): #get the module data lock, as we're updating a shared structure. _acquireLock() try: #unlikely to raise an exception, but you never know... - del _handlers[self] - _handlerList.remove(self) + if self in _handlers: + del _handlers[self] + if self in _handlerList: + _handlerList.remove(self) finally: _releaseLock() diff --git a/Misc/NEWS b/Misc/NEWS index f943618c69b..62d4e59a7bf 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -33,6 +33,8 @@ Core and Builtins Library ------- +- Issue #8581: logging: removed errors raised when closing handlers twice. + - Issue #4687: Fix accuracy of garbage collection runtimes displayed with gc.DEBUG_STATS.