diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-25 19:04:29 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-25 19:04:29 (GMT) |
commit | f81be8aa3ff3cbae66686482219bd7c7561f3de8 (patch) | |
tree | dcb8278ffce4c41cff723c1a12b94218f4baf591 /Lib/test/test_memoryview.py | |
parent | bc4ded953742bc4411faa3264505b4c61ac64827 (diff) | |
download | cpython-f81be8aa3ff3cbae66686482219bd7c7561f3de8.zip cpython-f81be8aa3ff3cbae66686482219bd7c7561f3de8.tar.gz cpython-f81be8aa3ff3cbae66686482219bd7c7561f3de8.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.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_memoryview.py b/Lib/test/test_memoryview.py index d2bab38..ddd5b9a 100644 --- a/Lib/test/test_memoryview.py +++ b/Lib/test/test_memoryview.py @@ -11,6 +11,8 @@ import gc import weakref import array import io +import copy +import pickle class AbstractMemoryTests: @@ -519,6 +521,17 @@ class OtherTest(unittest.TestCase): m2 = m1[::-1] self.assertEqual(m2.hex(), '30' * 200000) + 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) + if __name__ == "__main__": unittest.main() |