summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_memoryview.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-12-30 18:43:29 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-12-30 18:43:29 (GMT)
commitb8e54dd806e75f3591d8b7f07676a5738dad019d (patch)
treea7ba67021a3c201da7b5d0beffae25e16a479a79 /Lib/test/test_memoryview.py
parent2e6c8296817a8476cdb4c3c6ce6d79304379a4d7 (diff)
downloadcpython-b8e54dd806e75f3591d8b7f07676a5738dad019d.zip
cpython-b8e54dd806e75f3591d8b7f07676a5738dad019d.tar.gz
cpython-b8e54dd806e75f3591d8b7f07676a5738dad019d.tar.bz2
Issue #22995: Instances of extension types with a state that aren't
subclasses of list or dict and haven't implemented any pickle-related methods (__reduce__, __reduce_ex__, __getnewargs__, __getnewargs_ex__, or __getstate__), can no longer be pickled. Including memoryview.
Diffstat (limited to 'Lib/test/test_memoryview.py')
-rw-r--r--Lib/test/test_memoryview.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_memoryview.py b/Lib/test/test_memoryview.py
index f14bafd..bc83247 100644
--- a/Lib/test/test_memoryview.py
+++ b/Lib/test/test_memoryview.py
@@ -10,6 +10,8 @@ import weakref
import array
from test import test_support
import io
+import copy
+import pickle
class AbstractMemoryTests:
@@ -354,6 +356,19 @@ class BytesMemorySliceSliceTest(unittest.TestCase,
#pass
+class OtherTest(unittest.TestCase):
+ def test_copy(self):
+ m = memoryview(b'abc')
+ with self.assertRaises(TypeError):
+ copy.copy(m)
+
+ def test_pickle(self):
+ m = memoryview(b'abc')
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+ with self.assertRaises(TypeError):
+ pickle.dumps(m, proto)
+
+
def test_main():
test_support.run_unittest(__name__)