Backport 69934: Register xrange() as a Sequence.

This commit is contained in:
Raymond Hettinger 2009-02-24 12:23:23 +00:00
parent c9332fada6
commit 8c56f8890e
2 changed files with 4 additions and 0 deletions

View File

@ -519,6 +519,7 @@ class Sequence(Sized, Iterable, Container):
Sequence.register(tuple)
Sequence.register(basestring)
Sequence.register(buffer)
Sequence.register(xrange)
class MutableSequence(Sequence):

View File

@ -406,6 +406,9 @@ class TestCollectionABCs(ABCTestCase):
self.failUnless(isinstance(sample(), Sequence))
self.failUnless(issubclass(sample, Sequence))
self.failUnless(issubclass(basestring, Sequence))
self.failUnless(isinstance(range(10), Sequence))
self.failUnless(issubclass(xrange, Sequence))
self.failUnless(issubclass(str, Sequence))
self.validate_abstract_methods(Sequence, '__contains__', '__iter__', '__len__',
'__getitem__')