range() should have been registered as a Sequence.

Needs to be backported to 2.6, 2.7, and 3.0.
This commit is contained in:
Raymond Hettinger 2009-02-24 11:25:35 +00:00
parent afd3045025
commit 9aa53c2f01
2 changed files with 3 additions and 0 deletions

View File

@ -546,6 +546,7 @@ class Sequence(Sized, Iterable, Container):
Sequence.register(tuple)
Sequence.register(str)
Sequence.register(range)
class ByteString(Sequence):

View File

@ -406,6 +406,8 @@ class TestCollectionABCs(ABCTestCase):
for sample in [tuple, list, bytes, str]:
self.failUnless(isinstance(sample(), Sequence))
self.failUnless(issubclass(sample, Sequence))
self.failUnless(isinstance(range(10), Sequence))
self.failUnless(issubclass(range, Sequence))
self.failUnless(issubclass(str, Sequence))
self.validate_abstract_methods(Sequence, '__contains__', '__iter__', '__len__',
'__getitem__')