14
0
Files
python-colorlog/support-python-313.patch
Steve Kowalik 1ec0a017b6 - Switch to autosetup and pyproject macros.
- Set this package to noarch, since it doesn't ship any arch-dep files.
- Add patch support-python-313.patch:
  * Support Python 3.13's logging changes.

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-colorlog?expand=0&rev=28
2024-10-29 04:30:41 +00:00

55 lines
1.5 KiB
Diff

From 607485def2d60b60c40c0d682574324b47fc30ba Mon Sep 17 00:00:00 2001
From: Sam Clements <sam@borntyping.co.uk>
Date: Fri, 26 Jan 2024 14:06:47 +0000
Subject: [PATCH] Support Python 3.13
---
.github/workflows/ci.yml | 2 ++
colorlog/wrappers.py | 17 +++++++++++++----
setup.py | 2 +-
tox.ini | 2 +-
4 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/colorlog/wrappers.py b/colorlog/wrappers.py
index 20e3042..63b201a 100644
--- a/colorlog/wrappers.py
+++ b/colorlog/wrappers.py
@@ -2,6 +2,7 @@
import functools
import logging
+import sys
import typing
from logging import (
CRITICAL,
@@ -53,8 +54,8 @@ def basicConfig(
) -> None:
"""Call ``logging.basicConfig`` and override the formatter it creates."""
logging.basicConfig(**kwargs)
- logging._acquireLock() # type: ignore
- try:
+
+ def _basicConfig():
handler = logging.root.handlers[0]
handler.setFormatter(
colorlog.formatter.ColoredFormatter(
@@ -67,8 +68,16 @@ def basicConfig(
stream=kwargs.get("stream", None),
)
)
- finally:
- logging._releaseLock() # type: ignore
+
+ if sys.version_info >= (3, 13):
+ with logging._lock:
+ _basicConfig()
+ else:
+ logging._acquireLock() # type: ignore
+ try:
+ _basicConfig()
+ finally:
+ logging._releaseLock() # type: ignore
def ensure_configured(func):