[Python-checkins] cpython: Close #18690: register memoryview with Sequence ABC
nick.coghlan
python-checkins at python.org
Wed Oct 2 14:32:17 CEST 2013
http://hg.python.org/cpython/rev/95badf936353
changeset: 85924:95badf936353
user: Nick Coghlan <ncoghlan at gmail.com>
date: Wed Oct 02 22:31:47 2013 +1000
summary:
Close #18690: register memoryview with Sequence ABC
files:
Doc/library/stdtypes.rst | 4 ++++
Lib/collections/abc.py | 1 +
Lib/test/test_collections.py | 2 ++
Misc/NEWS | 3 +++
4 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -2458,6 +2458,10 @@
.. 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)
diff --git a/Lib/collections/abc.py b/Lib/collections/abc.py
--- a/Lib/collections/abc.py
+++ b/Lib/collections/abc.py
@@ -643,6 +643,7 @@
Sequence.register(tuple)
Sequence.register(str)
Sequence.register(range)
+Sequence.register(memoryview)
class ByteString(Sequence):
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -782,6 +782,8 @@
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__')
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
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)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list