From 2ce9d244b4a8db1ed22d41df33701620633cf320 Mon Sep 17 00:00:00 2001 From: JinWang An Date: Mon, 27 Mar 2023 17:02:58 +0900 Subject: [PATCH] Imported Upstream version 65.6.3 --- .bumpversion.cfg | 2 +- CHANGES.rst | 10 ++++++++++ setup.cfg | 2 +- setuptools/logging.py | 3 ++- setuptools/tests/test_logging.py | 17 +++++++++++++++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index db5a5c5..38dbe69 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 65.6.2 +current_version = 65.6.3 commit = True tag = True diff --git a/CHANGES.rst b/CHANGES.rst index 6d57c8f..4f4ede6 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,13 @@ +v65.6.3 +------- + + +Misc +^^^^ +* #3709: Fix condition to patch ``distutils.dist.log`` to only apply when using + ``distutils`` from the stdlib. + + v65.6.2 ------- diff --git a/setup.cfg b/setup.cfg index 0e18e06..99c1bec 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = setuptools -version = 65.6.2 +version = 65.6.3 author = Python Packaging Authority author_email = distutils-sig@python.org description = Easily download, build, install, upgrade, and uninstall Python packages diff --git a/setuptools/logging.py b/setuptools/logging.py index e99c1b9..0653878 100644 --- a/setuptools/logging.py +++ b/setuptools/logging.py @@ -1,4 +1,5 @@ import sys +import inspect import logging import distutils.log from . import monkey @@ -22,7 +23,7 @@ def configure(): handlers = err_handler, out_handler logging.basicConfig( format="{message}", style='{', handlers=handlers, level=logging.DEBUG) - if hasattr(distutils.log, 'Log'): + if inspect.ismodule(distutils.dist.log): monkey.patch_func(set_threshold, distutils.log, 'set_threshold') # For some reason `distutils.log` module is getting cached in `distutils.dist` # and then loaded again when patched, diff --git a/setuptools/tests/test_logging.py b/setuptools/tests/test_logging.py index a5ddd56..aa2b502 100644 --- a/setuptools/tests/test_logging.py +++ b/setuptools/tests/test_logging.py @@ -1,4 +1,6 @@ +import inspect import logging +import os import pytest @@ -34,3 +36,18 @@ def test_verbosity_level(tmp_path, monkeypatch, flag, expected_level): log_level = logger.getEffectiveLevel() log_level_name = logging.getLevelName(log_level) assert log_level_name == expected_level + + +def test_patching_does_not_cause_problems(): + # Ensure `dist.log` is only patched if necessary + + import setuptools.logging + from distutils import dist + + setuptools.logging.configure() + + if os.getenv("SETUPTOOLS_USE_DISTUTILS", "local").lower() == "local": + # Modern logging infra, no problematic patching. + assert isinstance(dist.log, logging.Logger) + else: + assert inspect.ismodule(dist.log) -- 2.34.1