ref: Remove residual Python 2 compatibility code - #7421
Open
DragonBot00 wants to merge 1 commit into
Open
Conversation
Python 2 support was dropped in SDK 2.0.0. Clean up leftover shims: - Remove with_metaclass() from _compat.py, use native metaclass= keyword - Drop try/except for ModuleNotFoundError (available since Python 3.6) - Replace super(_Client, self) with super() - Remove im_class/im_func try/except in qualname_from_function - Remove __name__ fallbacks where __qualname__ is always available - Remove stale py2/py2.7 comments from Django middleware and tests - Simplify IOError/except patterns (IOError is OSError in Python 3) - Remove except AttributeError guards around nanosecond_time() - Remove bist_wheel universal=1 from setup.py No behavior change. Minimum supported Python stays at 3.6.
alexander-alderman-webb
requested changes
Sep 8, 2026
alexander-alderman-webb
left a comment
Contributor
There was a problem hiding this comment.
This is a bunch of mostly unrelated changes that have some behavior change.
I'd suggest changing one thing at a time instead.
Comment on lines
-21
to
-22
| elif hasattr(receiver, "__name__"): # Python 2.7 has no __qualname__ | ||
| name = receiver.__name__ |
Contributor
There was a problem hiding this comment.
Not every function has __qualname__ in Python, so this is not purely Python 2 compat.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Python 2 support was dropped in SDK 2.0.0, but a handful of Python 2 shims, unreachable branches, and stale \py2\ comments lingered. This PR cleans them up. No behavior change.
anosecond_time()\ calls.
Minimum supported Python stays at 3.6.
Closes #6120
Test plan