Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(24)

Side by Side Diff: Lib/_collections_abc.py

Issue 28376: assertion failure in rangeobject.c
Patch Set: Created 3 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Lib/test/test_range.py » ('j') | Lib/test/test_range.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2007 Google, Inc. All Rights Reserved. 1 # Copyright 2007 Google, Inc. All Rights Reserved.
2 # Licensed to PSF under a Contributor Agreement. 2 # Licensed to PSF under a Contributor Agreement.
3 3
4 """Abstract Base Classes (ABCs) for collections, according to PEP 3119. 4 """Abstract Base Classes (ABCs) for collections, according to PEP 3119.
5 5
6 Unit tests are in test_collections. 6 Unit tests are in test_collections.
7 """ 7 """
8 8
9 from abc import ABCMeta, abstractmethod 9 from abc import ABCMeta, abstractmethod
10 import sys 10 import sys
(...skipping 11 matching lines...) Expand all
22 # This module has been renamed from collections.abc to _collections_abc to 22 # This module has been renamed from collections.abc to _collections_abc to
23 # speed up interpreter startup. Some of the types such as MutableMapping are 23 # speed up interpreter startup. Some of the types such as MutableMapping are
24 # required early but collections module imports a lot of other modules. 24 # required early but collections module imports a lot of other modules.
25 # See issue #19218 25 # See issue #19218
26 __name__ = "collections.abc" 26 __name__ = "collections.abc"
27 27
28 # Private list of types that we want to register with the various ABCs 28 # Private list of types that we want to register with the various ABCs
29 # so that they will pass tests like: 29 # so that they will pass tests like:
30 # it = iter(somebytearray) 30 # it = iter(somebytearray)
31 # assert isinstance(it, Iterable) 31 # assert isinstance(it, Iterable)
32 # Note: in other implementations, these types many not be distinct 32 # Note: in other implementations, these types might not be distinct
storchaka 2016/10/07 14:32:00 Nice catch!
33 # and they make have their own implementation specific types that 33 # and they may have their own implementation specific types that
34 # are not included on this list. 34 # are not included on this list.
35 bytes_iterator = type(iter(b'')) 35 bytes_iterator = type(iter(b''))
36 bytearray_iterator = type(iter(bytearray())) 36 bytearray_iterator = type(iter(bytearray()))
37 #callable_iterator = ??? 37 #callable_iterator = ???
38 dict_keyiterator = type(iter({}.keys())) 38 dict_keyiterator = type(iter({}.keys()))
39 dict_valueiterator = type(iter({}.values())) 39 dict_valueiterator = type(iter({}.values()))
40 dict_itemiterator = type(iter({}.items())) 40 dict_itemiterator = type(iter({}.items()))
41 list_iterator = type(iter([])) 41 list_iterator = type(iter([]))
42 list_reverseiterator = type(iter(reversed([]))) 42 list_reverseiterator = type(iter(reversed([])))
43 range_iterator = type(iter(range(0))) 43 range_iterator = type(iter(range(0)))
44 longrange_iterator = type(iter(range(1 << 1000)))
44 set_iterator = type(iter(set())) 45 set_iterator = type(iter(set()))
45 str_iterator = type(iter("")) 46 str_iterator = type(iter(""))
46 tuple_iterator = type(iter(())) 47 tuple_iterator = type(iter(()))
47 zip_iterator = type(iter(zip())) 48 zip_iterator = type(iter(zip()))
48 ## views ## 49 ## views ##
49 dict_keys = type({}.keys()) 50 dict_keys = type({}.keys())
50 dict_values = type({}.values()) 51 dict_values = type({}.values())
51 dict_items = type({}.items()) 52 dict_items = type({}.items())
52 ## misc ## 53 ## misc ##
53 mappingproxy = type(type.__dict__) 54 mappingproxy = type(type.__dict__)
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 219
219 Iterator.register(bytes_iterator) 220 Iterator.register(bytes_iterator)
220 Iterator.register(bytearray_iterator) 221 Iterator.register(bytearray_iterator)
221 #Iterator.register(callable_iterator) 222 #Iterator.register(callable_iterator)
222 Iterator.register(dict_keyiterator) 223 Iterator.register(dict_keyiterator)
223 Iterator.register(dict_valueiterator) 224 Iterator.register(dict_valueiterator)
224 Iterator.register(dict_itemiterator) 225 Iterator.register(dict_itemiterator)
225 Iterator.register(list_iterator) 226 Iterator.register(list_iterator)
226 Iterator.register(list_reverseiterator) 227 Iterator.register(list_reverseiterator)
227 Iterator.register(range_iterator) 228 Iterator.register(range_iterator)
229 Iterator.register(longrange_iterator)
storchaka 2016/10/07 14:32:00 Is this needed? isinstance(iter(range(1<<1000)), c
Oren Milman 2016/10/07 16:10:00 Indeed. That's because Iterator has a __subclassho
storchaka 2016/10/07 16:44:09 I think the same. But for sure I have asked on Pyt
Oren Milman 2016/10/08 13:08:05 IIUC (according to the mail you sent to Python-Dev
storchaka 2016/10/08 17:58:22 Guido said the registrations should stay. And I t
228 Iterator.register(set_iterator) 230 Iterator.register(set_iterator)
229 Iterator.register(str_iterator) 231 Iterator.register(str_iterator)
230 Iterator.register(tuple_iterator) 232 Iterator.register(tuple_iterator)
231 Iterator.register(zip_iterator) 233 Iterator.register(zip_iterator)
232 234
233 235
234 class Reversible(Iterable): 236 class Reversible(Iterable):
235 237
236 __slots__ = () 238 __slots__ = ()
237 239
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 Raise ValueError if the value is not present. 941 Raise ValueError if the value is not present.
940 ''' 942 '''
941 del self[self.index(value)] 943 del self[self.index(value)]
942 944
943 def __iadd__(self, values): 945 def __iadd__(self, values):
944 self.extend(values) 946 self.extend(values)
945 return self 947 return self
946 948
947 MutableSequence.register(list) 949 MutableSequence.register(list)
948 MutableSequence.register(bytearray) # Multiply inheriting, see ByteString 950 MutableSequence.register(bytearray) # Multiply inheriting, see ByteString
OLDNEW
« no previous file with comments | « no previous file | Lib/test/test_range.py » ('j') | Lib/test/test_range.py » ('J')

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+