diff options
author | Nadeem Vawda <nadeem.vawda@gmail.com> | 2013-10-28 20:41:24 (GMT) |
---|---|---|
committer | Nadeem Vawda <nadeem.vawda@gmail.com> | 2013-10-28 20:41:24 (GMT) |
commit | e6514f533efba25e5aeba50208515d02d528995a (patch) | |
tree | 9895781bdec365d927ee7669366773119c5164ad /Lib/test/test_lzma.py | |
parent | d1b48998e5b404387c8f0942197189ba3207c15e (diff) | |
parent | 3797065ac55997741fd625a30a8308c04ee5c9b9 (diff) | |
download | cpython-e6514f533efba25e5aeba50208515d02d528995a.zip cpython-e6514f533efba25e5aeba50208515d02d528995a.tar.gz cpython-e6514f533efba25e5aeba50208515d02d528995a.tar.bz2 |
#19395: Raise exception when pickling a (BZ2|LZMA)(Compressor|Decompressor).
The underlying C libraries provide no mechanism for serializing compressor and
decompressor objects, so actually pickling these classes is impractical.
Previously, these objects would be pickled without error, but attempting to use
a deserialized instance would segfault the interpreter.
Diffstat (limited to 'Lib/test/test_lzma.py')
-rw-r--r-- | Lib/test/test_lzma.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_lzma.py b/Lib/test/test_lzma.py index b6af563..26d19da 100644 --- a/Lib/test/test_lzma.py +++ b/Lib/test/test_lzma.py @@ -1,5 +1,6 @@ from io import BytesIO, UnsupportedOperation import os +import pickle import random import unittest @@ -216,6 +217,14 @@ class CompressorDecompressorTestCase(unittest.TestCase): finally: input = cdata = ddata = None + # Pickling raises an exception; there's no way to serialize an lzma_stream. + + def test_pickle(self): + with self.assertRaises(TypeError): + pickle.dumps(LZMACompressor()) + with self.assertRaises(TypeError): + pickle.dumps(LZMADecompressor()) + class CompressDecompressFunctionTestCase(unittest.TestCase): |