mirror of
https://github.com/python/cpython.git
synced 2025-08-25 19:24:42 +00:00
Fix for bug #1109
Warning required when calling register() on an ABCMeta subclass.
This commit is contained in:
parent
c896700235
commit
2e510fb920
2 changed files with 11 additions and 1 deletions
|
@ -137,8 +137,11 @@ class ABCMeta(type):
|
|||
cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
|
||||
return cls
|
||||
|
||||
def register(cls, subclass):
|
||||
def register(cls, subclass=None):
|
||||
"""Register a virtual subclass of an ABC."""
|
||||
if subclass is None:
|
||||
raise TypeError("register() cannot be called on an ABCMeta "
|
||||
"subclass, use class Example(metaclass=abc.ABCMeta) instead.")
|
||||
if not isinstance(cls, type):
|
||||
raise TypeError("Can only register classes")
|
||||
if issubclass(subclass, cls):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue