Skip to content

Fix _BaseConfigurator.__new__ crash for subclasses with __init__ arguments#5441

Open
Eason09053360 wants to merge 2 commits into
open-telemetry:mainfrom
Eason09053360:fix-baseconfigurator-new-with-args
Open

Fix _BaseConfigurator.__new__ crash for subclasses with __init__ arguments#5441
Eason09053360 wants to merge 2 commits into
open-telemetry:mainfrom
Eason09053360:fix-baseconfigurator-new-with-args

Conversation

@Eason09053360

@Eason09053360 Eason09053360 commented Jul 19, 2026

Copy link
Copy Markdown

Description

_BaseConfigurator.__new__ forwards *args, **kwargs to object.__new__. Since _BaseConfigurator overrides __new__, CPython's object.__new__ raises TypeError: object.__new__() takes exactly one argument when it receives any extra arguments. As a result, any distro Configurator subclass that defines an __init__ with parameters (an extension pattern the docs encourage) crashes on first instantiation.

Fix: call object.__new__(cls) without forwarding arguments — type.__call__ still passes them to __init__. The singleton behavior is unchanged.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Added test_custom_configurator_with_init_args, which fails with the TypeError above before the fix and passes after.
  • Existing TestConfigurator tests still pass.

Does This PR Require a Contrib Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

…ments

object.__new__ raises TypeError when passed extra arguments if __new__
is overridden, so any Configurator subclass defining an __init__ with
parameters crashed on first instantiation. Call object.__new__(cls)
without forwarding arguments; type.__call__ still passes them to
__init__.
@Eason09053360
Eason09053360 marked this pull request as ready for review July 20, 2026 11:33
@Eason09053360
Eason09053360 requested a review from a team as a code owner July 20, 2026 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant