#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:
Nadeem Vawda 2013-10-28 21:41:24 +01:00
commit e6514f533e
4 changed files with 57 additions and 2 deletions

View file

@ -5,6 +5,7 @@ from test.support import bigmemtest, _4G
import unittest
from io import BytesIO
import os
import pickle
import random
import subprocess
import sys
@ -628,6 +629,11 @@ class BZ2CompressorTest(BaseTest):
finally:
data = None
def testPickle(self):
with self.assertRaises(TypeError):
pickle.dumps(BZ2Compressor())
class BZ2DecompressorTest(BaseTest):
def test_Constructor(self):
self.assertRaises(TypeError, BZ2Decompressor, 42)
@ -679,6 +685,10 @@ class BZ2DecompressorTest(BaseTest):
compressed = None
decompressed = None
def testPickle(self):
with self.assertRaises(TypeError):
pickle.dumps(BZ2Decompressor())
class CompressDecompressTest(BaseTest):
def testCompress(self):