Kaydet (Commit) cf5e1d82 authored tarafından Nadeem Vawda's avatar Nadeem Vawda

Tidy up comments from dd4f7d5c51c7 (zlib compression dictionary support).

üst a425c3d5
...@@ -427,24 +427,23 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase): ...@@ -427,24 +427,23 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
def test_dictionary(self): def test_dictionary(self):
h = HAMLET_SCENE h = HAMLET_SCENE
# build a simulated dictionary out of the words in HAMLET # Build a simulated dictionary out of the words in HAMLET.
words = h.split() words = h.split()
random.shuffle(words) random.shuffle(words)
zdict = b''.join(words) zdict = b''.join(words)
# use it to compress HAMLET # Use it to compress HAMLET.
co = zlib.compressobj(zdict=zdict) co = zlib.compressobj(zdict=zdict)
cd = co.compress(h) + co.flush() cd = co.compress(h) + co.flush()
# verify that it will decompress with the dictionary # Verify that it will decompress with the dictionary.
dco = zlib.decompressobj(zdict=zdict) dco = zlib.decompressobj(zdict=zdict)
self.assertEqual(dco.decompress(cd) + dco.flush(), h) self.assertEqual(dco.decompress(cd) + dco.flush(), h)
# verify that it fails when not given the dictionary # Verify that it fails when not given the dictionary.
dco = zlib.decompressobj() dco = zlib.decompressobj()
self.assertRaises(zlib.error, dco.decompress, cd) self.assertRaises(zlib.error, dco.decompress, cd)
def test_dictionary_streaming(self): def test_dictionary_streaming(self):
# this is simulating the needs of SPDY to be able to reuse the same # This simulates the reuse of a compressor object for compressing
# stream object (with its compression state) between sets of compressed # several separate data streams.
# headers.
co = zlib.compressobj(zdict=HAMLET_SCENE) co = zlib.compressobj(zdict=HAMLET_SCENE)
do = zlib.decompressobj(zdict=HAMLET_SCENE) do = zlib.decompressobj(zdict=HAMLET_SCENE)
piece = HAMLET_SCENE[1000:1500] piece = HAMLET_SCENE[1000:1500]
......
...@@ -619,7 +619,7 @@ PyZlib_objdecompress(compobject *self, PyObject *args) ...@@ -619,7 +619,7 @@ PyZlib_objdecompress(compobject *self, PyObject *args)
RetVal = NULL; RetVal = NULL;
goto error; goto error;
} }
/* repeat the call to inflate! */ /* Repeat the call to inflate. */
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
err = inflate(&(self->zst), Z_SYNC_FLUSH); err = inflate(&(self->zst), Z_SYNC_FLUSH);
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment