Skip to content

Conversation

@MikeGoldsmith
Copy link
Member

@MikeGoldsmith MikeGoldsmith commented Feb 11, 2026

Description

Fixes AttributeError when invalid attribute types are passed in Python 3.9. The typing.Mapping type lacks __name__ attribute in py39, causing error message generation to fail with AttributeError instead of the intended TypeError.

Added _get_type_name() helper to safely extract type names from both regular types and typing generics.

Fixes:

Type of change

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

How Has This Been Tested?

  • Added regression test test_invalid_type_error_message
  • All existing tests pass on Python 3.9 and 3.12
  • Verified error messages include valid types without raising AttributeError

Does This PR Require a Contrib Repo Change?

  • No.

Checklist:

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

typing.Mapping lacks __name__ in py39, causing AttributeError instead of TypeError when invalid types passed to attributes.

Fixes open-telemetry#4821
@MikeGoldsmith MikeGoldsmith requested a review from a team as a code owner February 11, 2026 15:24
@xrmx
Copy link
Contributor

xrmx commented Feb 12, 2026

Isn't this a dup of #4876 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants