tests: Update private logging API usage for Python 3.13

See https://github.com/python/cpython/issues/109461
Using it as a context manager already works fine in earlier Python versions too.

See #8205
This commit is contained in:
Florian Bruhin 2024-06-25 08:14:20 +02:00
parent b3b9678699
commit d0cc8d4fe9
1 changed files with 1 additions and 4 deletions

View File

@ -27,8 +27,7 @@ def restore_loggers():
"""
logging.captureWarnings(False)
logger_dict = logging.getLogger().manager.loggerDict
logging._acquireLock()
try:
with logging._lock:
saved_handlers = logging._handlers.copy()
saved_handler_list = logging._handlerList[:]
saved_loggers = saved_loggers = logger_dict.copy()
@ -37,8 +36,6 @@ def restore_loggers():
logger_states = {}
for name in saved_loggers:
logger_states[name] = getattr(saved_loggers[name], 'disabled', None)
finally:
logging._releaseLock()
root_logger = logging.getLogger("")
root_handlers = root_logger.handlers[:]