mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
keep UserDict an old-style class
Be generous in abc.py to allow this.
This commit is contained in:
parent
3ceab01cef
commit
bde67df0cd
3 changed files with 4 additions and 4 deletions
|
@ -3,6 +3,8 @@
|
|||
|
||||
"""Abstract Base Classes (ABCs) according to PEP 3119."""
|
||||
|
||||
import types
|
||||
|
||||
|
||||
# Instance of old-style class
|
||||
class _C: pass
|
||||
|
@ -101,7 +103,7 @@ class ABCMeta(type):
|
|||
|
||||
def register(cls, subclass):
|
||||
"""Register a virtual subclass of an ABC."""
|
||||
if not isinstance(subclass, type):
|
||||
if not isinstance(subclass, (type, types.ClassType)):
|
||||
raise TypeError("Can only register classes")
|
||||
if issubclass(subclass, cls):
|
||||
return # Already a subclass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue