mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
[3.12] gh-107576: Ensure __orig_bases__
are our own in get_original_bases
(GH-107584) (#107592)
gh-107576: Ensure `__orig_bases__` are our own in `get_original_bases` (GH-107584)
(cherry picked from commit ed4a978449
)
Co-authored-by: James Hilton-Balfe <gobot1234yt@gmail.com>
Co-authored-by: Chris Bouchard <chris@upliftinglemma.net>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
93fcf75878
commit
d2c7b25afb
3 changed files with 20 additions and 7 deletions
11
Lib/types.py
11
Lib/types.py
|
@ -165,14 +165,11 @@ def get_original_bases(cls, /):
|
|||
assert get_original_bases(int) == (object,)
|
||||
"""
|
||||
try:
|
||||
return cls.__orig_bases__
|
||||
return cls.__dict__.get("__orig_bases__", cls.__bases__)
|
||||
except AttributeError:
|
||||
try:
|
||||
return cls.__bases__
|
||||
except AttributeError:
|
||||
raise TypeError(
|
||||
f'Expected an instance of type, not {type(cls).__name__!r}'
|
||||
) from None
|
||||
raise TypeError(
|
||||
f"Expected an instance of type, not {type(cls).__name__!r}"
|
||||
) from None
|
||||
|
||||
|
||||
class DynamicClassAttribute:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue