mirror of
https://github.com/python/cpython.git
synced 2025-11-24 20:30:18 +00:00
gh-107576: Ensure __orig_bases__ are our own in get_original_bases (#107584)
Co-authored-by: Chris Bouchard <chris@upliftinglemma.net> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
77e09192b5
commit
ed4a978449
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