mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
#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.
This commit is contained in:
commit
e6514f533e
4 changed files with 57 additions and 2 deletions
|
|
@ -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):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue