Skip to content

Commit

Permalink
Support Python 3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
borntyping committed Jan 26, 2024
1 parent 3d95fe8 commit 607485d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
dependencies:
- ""
- "colorama"
Expand All @@ -44,6 +45,7 @@ jobs:
uses: "actions/setup-python@v2"
with:
python-version: "${{ matrix.python-version }}"
allow-prereleases: true
- name: "🐍 Display Python version"
run: "python --version"
- name: "🐍 Install dependencies"
Expand Down
17 changes: 13 additions & 4 deletions colorlog/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import functools
import logging
import sys
import typing
from logging import (
CRITICAL,
Expand Down Expand Up @@ -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(
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="colorlog",
version="6.8.2",
version="6.8.3",
description="Add colours to the output of Python's logging module.",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = black,flake8,mypy,py38,py39,py310,py311,py312
envlist = black,flake8,mypy,py38,py39,py310,py311,py312,py313

[testenv]
deps = pytest
Expand Down

0 comments on commit 607485d

Please sign in to comment.