Skip to content

Fix AttributeError on Python 3.9 when invalid type passed to attributes#4933

Closed
thakoreh wants to merge 2 commits intoopen-telemetry:mainfrom
thakoreh:fix-python39-attribute-error
Closed

Fix AttributeError on Python 3.9 when invalid type passed to attributes#4933
thakoreh wants to merge 2 commits intoopen-telemetry:mainfrom
thakoreh:fix-python39-attribute-error

Conversation

@thakoreh
Copy link

Description

Fixes issue #4821 - Incorrect error when passing wrong attribute type on Python 3.9

The issue is that on Python 3.9, and don't have attribute, which causes an instead of the expected when an invalid type is passed.

Changes

  • Added helper function that handles typing module edge cases
  • Updated error message to use instead of direct access

Root Cause

The fix uses and falls back to or for typing module types.

Test

The fix can be verified by running:

Before fix:
After fix:

Add _get_type_name helper to handle typing module types that don't have
__name__ attribute on Python 3.9 (like Sequence, Mapping).

Fixes: open-telemetry#4821
@thakoreh thakoreh requested a review from a team as a code owner February 24, 2026 14:03
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Feb 24, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

@thakoreh
Copy link
Author

The CI is failing because no CHANGELOG entry was added. You can either:

  1. Add a changelog entry to the appropriate CHANGELOG.md file
  2. Add the "Skip Changelog" label if this change doesn't require a changelog entry

This looks like a bug fix, so a changelog entry would be appropriate.

@xrmx
Copy link
Contributor

xrmx commented Feb 26, 2026

@thakoreh we already have two open PRs for this, we don't need more 😅

@xrmx xrmx closed this Feb 26, 2026
@github-project-automation github-project-automation bot moved this from Ready for review to Done in @xrmx's Python PR digest Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants