mirror of
https://github.com/python/cpython.git
synced 2025-12-07 09:47:28 +00:00
Merge r60679
This commit is contained in:
parent
77c02ebf38
commit
74b6495b34
1 changed files with 4 additions and 30 deletions
|
|
@ -82,7 +82,7 @@ class Iterable(metaclass=ABCMeta):
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
|
|
||||||
|
|
||||||
class Iterator(metaclass=ABCMeta):
|
class Iterator(Iterable):
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def __next__(self):
|
def __next__(self):
|
||||||
|
|
@ -157,7 +157,7 @@ class Callable(metaclass=ABCMeta):
|
||||||
### SETS ###
|
### SETS ###
|
||||||
|
|
||||||
|
|
||||||
class Set(metaclass=ABCMeta):
|
class Set(Sized, Iterable, Container):
|
||||||
|
|
||||||
"""A set is a finite, iterable container.
|
"""A set is a finite, iterable container.
|
||||||
|
|
||||||
|
|
@ -169,19 +169,6 @@ class Set(metaclass=ABCMeta):
|
||||||
then the other operations will automatically follow suit.
|
then the other operations will automatically follow suit.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def __contains__(self, value):
|
|
||||||
return False
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def __iter__(self):
|
|
||||||
while False:
|
|
||||||
yield None
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def __len__(self):
|
|
||||||
return 0
|
|
||||||
|
|
||||||
def __le__(self, other):
|
def __le__(self, other):
|
||||||
if not isinstance(other, Set):
|
if not isinstance(other, Set):
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
|
|
@ -358,7 +345,7 @@ MutableSet.register(set)
|
||||||
### MAPPINGS ###
|
### MAPPINGS ###
|
||||||
|
|
||||||
|
|
||||||
class Mapping(metaclass=ABCMeta):
|
class Mapping(Sized, Iterable, Container):
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
|
|
@ -378,15 +365,6 @@ class Mapping(metaclass=ABCMeta):
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def __len__(self):
|
|
||||||
return 0
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def __iter__(self):
|
|
||||||
while False:
|
|
||||||
yield None
|
|
||||||
|
|
||||||
def keys(self):
|
def keys(self):
|
||||||
return KeysView(self)
|
return KeysView(self)
|
||||||
|
|
||||||
|
|
@ -523,7 +501,7 @@ MutableMapping.register(dict)
|
||||||
### SEQUENCES ###
|
### SEQUENCES ###
|
||||||
|
|
||||||
|
|
||||||
class Sequence(metaclass=ABCMeta):
|
class Sequence(Sized, Iterable, Container):
|
||||||
|
|
||||||
"""All the operations on a read-only sequence.
|
"""All the operations on a read-only sequence.
|
||||||
|
|
||||||
|
|
@ -535,10 +513,6 @@ class Sequence(metaclass=ABCMeta):
|
||||||
def __getitem__(self, index):
|
def __getitem__(self, index):
|
||||||
raise IndexError
|
raise IndexError
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def __len__(self):
|
|
||||||
return 0
|
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
i = 0
|
i = 0
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue