python-colorlog icon indicating copy to clipboard operation
python-colorlog copied to clipboard

Does not work on Python 3.13

Open jwodder opened this issue 1 year ago • 1 comments

Attempting to use colorlog 6.8.2 under Python 3.13.0 like so:

import logging
import sys
import colorlog

colorlog.basicConfig(
    format="%(log_color)s[%(levelname)-8s] %(message)s",
    log_colors={
        "DEBUG": "cyan",
        "INFO": "bold",
        "WARNING": "yellow",
        "ERROR": "red",
        "CRITICAL": "bold_red",
    },
    level=logging.DEBUG,
    stream=sys.stderr,
)
logging.info("Hello, world!")

results in the following error:

Traceback (most recent call last):
  File "/Users/jwodder/work/sand/python/libraries/colorlog-13.py", line 5, in <module>
    colorlog.basicConfig(
    ~~~~~~~~~~~~~~~~~~~~^
        format="%(log_color)s[%(levelname)-8s] %(message)s",
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<8 lines>...
        stream=sys.stderr,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/jwodder/.local/virtualenvwrapper/venvs/tmp-a8febeefddd48eb/lib/python3.13/site-packages/colorlog/wrappers.py", line 56, in basicConfig
    logging._acquireLock()  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'logging' has no attribute '_acquireLock'

jwodder avatar Oct 23 '24 16:10 jwodder

I think I've got a patch for this that I couldn't release at the time. I'll try and get that out soon.

borntyping avatar Oct 23 '24 20:10 borntyping

Should be fixed in 6.9.0, thanks for the issue!

borntyping avatar Oct 29 '24 18:10 borntyping