8000 `logging._handlerList` is modified when setuptools Distribution is created · Issue #1139 · pypa/setuptools-scm · GitHub
[go: up one dir, main page]

Skip to content
logging._handlerList is modified when setuptools Distribution is created #1139
@kulikjak

Description

@kulikjak

Hi, CPython recently turned warnings into errors in its test suite via python/cpython#131802, and one of the unfortunate effects of that change is that when setuptools_scm is available on the system, on of the tests fails because logging._handlerList is modified during the execution.

The problem is that when setuptools_scm is available, creating setuptools Distribution adds a new hander to the list. It can be easily reproduced with this:

import logging
print(logging._handlerList)

from setuptools import Distribution
dist = Distribution()
print(logging._handlerList)

which results in:

[<weakref at 0x7fc8fe73b970; to 'logging._StderrHandler' at 0x7fc8fef0e3c0>]
[<weakref at 0x7fc8fe73b970; to 'logging._StderrHandler' at 0x7fc8fef0e3c0>, <weakref at 0x7fc8fbadb8d0; to 'setuptools_scm._log.AlwaysStdErrHandler' at 0x7fc8f82bf4d0>]

which is unfortunate.

(It happens in Distribution.finalize_options where it loads all entry points in group "setuptools.finalize_distribution_options" - https://github.com/pypa/setuptools/blob/f37845bce6bb06ec25c24cf30210a485e945d21e/setuptools/dist.py#L786)

I reported the issue in the CPython issue tracker (python/cpython#133509 - more info is there) but after a discussion there I concluded that this is more of a setuptools_scm "issue" and I should ask here.

I am not sure whether this is a bug, but imho it's at least an unexpected side effect of just creating the Distribution instance. Should this be happening, and if so, is there a way of preventing this (or should be)? I believe this is the only setuptools plugin we have that is doing this.

Or (and I am aware this is more general question outside of setuptools_scm) would you maybe have a suggestion how to prevent the upstream Python test from failing? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0