]> granicus.if.org Git - python/commitdiff
Close #18690: register memoryview with Sequence ABC
authorNick Coghlan <ncoghlan@gmail.com>
Wed, 2 Oct 2013 12:31:47 +0000 (22:31 +1000)
committerNick Coghlan <ncoghlan@gmail.com>
Wed, 2 Oct 2013 12:31:47 +0000 (22:31 +1000)
Doc/library/stdtypes.rst
Lib/collections/abc.py
Lib/test/test_collections.py
Misc/NEWS

index cf989cf1da30a2e9dd82349bbe1e1d1a2f360ff3..bd275af1b0608b55114936150df964ea62d5c421 100644 (file)
@@ -2458,6 +2458,10 @@ copying.
    .. versionchanged:: 3.3
       One-dimensional memoryviews with formats 'B', 'b' or 'c' are now hashable.
 
+   .. versionchanged:: 3.4
+      memoryview is now registered automatically with
+      :class:`collections.abc.Sequence`
+
    :class:`memoryview` has several methods:
 
    .. method:: __eq__(exporter)
index a8681eaebd0f39b482ad9fc8167b96276d9a19b6..d19e5925a0afe181bc506b19b557418e2f0d73b2 100644 (file)
@@ -643,6 +643,7 @@ class Sequence(Sized, Iterable, Container):
 Sequence.register(tuple)
 Sequence.register(str)
 Sequence.register(range)
+Sequence.register(memoryview)
 
 
 class ByteString(Sequence):
index 706cc9e9b6d151733daf0f3cdb02b901c68f60c5..6c733eeb6f9389bccc3f2eea1db05dc2ffbd087e 100644 (file)
@@ -782,6 +782,8 @@ class TestCollectionABCs(ABCTestCase):
             self.assertTrue(issubclass(sample, Sequence))
         self.assertIsInstance(range(10), Sequence)
         self.assertTrue(issubclass(range, Sequence))
+        self.assertIsInstance(memoryview(b""), Sequence)
+        self.assertTrue(issubclass(memoryview, Sequence))
         self.assertTrue(issubclass(str, Sequence))
         self.validate_abstract_methods(Sequence, '__contains__', '__iter__', '__len__',
             '__getitem__')
index 71de0bb68b229af9d9f4b8fb03e3876433f63326..f7a118c12fabf938b4126378243da8c52d40d9ea 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ Projected release date: 2013-10-20
 Core and Builtins
 -----------------
 
+- Issue #18690: memoryview is now automatically registered with
+  collections.abc.Sequence
+
 - Issue #19078: memoryview now correctly supports the reversed builtin
   (Patch by Claudiu Popa)