Backport 69934: Register xrange() as a Sequence.

This commit is contained in:
Raymond Hettinger 2009-02-24 12:25:32 +00:00
parent 54fba82310
commit 9293eb965a
3 changed files with 6 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

@ -393,6 +393,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__')

View File

@ -12,6 +12,8 @@ What's New in Python 2.6.2
Core and Builtins
-----------------
- xrange() is now registered as a Sequence.
- Issue #5247: Improve error message when unknown format codes are
used when using str.format() with str, unicode, long, int, and
float arguments.