Skip to content

Commit d0feb6a

Browse files
committed
Merge branch 'zstd-set-pledged-input-size' of github.com:emmatyping/cpython into zstd-set-pledged-input-size
2 parents 6b52d45 + fe78bac commit d0feb6a

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

Doc/library/compression.zstd.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,11 @@ Compressing and decompressing data in memory
260260
If :attr:`last_mode` is not :attr:`FLUSH_FRAME`, a
261261
:exc:`ValueError` is raised as the compressor is not at the start of
262262
a frame. If the pledged size does not match the actual size of data
263-
provided to :meth:`~.compress`, future calls to :meth:`~.compress` or
263+
provided to :meth:`.compress`, future calls to :meth:`!compress` or
264264
:meth:`flush` may raise :exc:`ZstdError` and the last chunk of data may
265265
be lost.
266266

267-
After :meth:`flush` or :meth:`~.compress` are called with mode
267+
After :meth:`flush` or :meth:`.compress` are called with mode
268268
:attr:`FLUSH_FRAME`, the next frame will not include the frame size into
269269
the header unless :meth:`!set_pledged_input_size` is called again.
270270

@@ -648,7 +648,7 @@ Advanced parameter control
648648
Write the size of the data to be compressed into the Zstandard frame
649649
header when known prior to compressing.
650650

651-
This flag only takes effect under the following three scenarios:
651+
This flag only takes effect under the following scenarios:
652652

653653
* Calling :func:`compress` for one-shot compression
654654
* Providing all of the data to be compressed in the frame in a single

Modules/_zstd/compressor.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -747,8 +747,8 @@ _zstd.ZstdCompressor.set_pledged_input_size
747747
Set the uncompressed content size to be written into the frame header.
748748
749749
This method can be used to ensure the header of the frame about to be written
750-
includes the size of the data, unless CompressionParameter.content_size_flag is
751-
set to False. If last_mode != FLUSH_FRAME, then a RuntimeError is raised.
750+
includes the size of the data, unless the CompressionParameter.content_size_flag
751+
is set to False. If last_mode != FLUSH_FRAME, then a RuntimeError is raised.
752752
753753
It is important to ensure that the pledged data size matches the actual data
754754
size. If they do not match the compressed output data may be corrupted and the
@@ -760,8 +760,6 @@ _zstd_ZstdCompressor_set_pledged_input_size_impl(ZstdCompressor *self,
760760
unsigned long long size)
761761
/*[clinic end generated code: output=3a09e55cc0e3b4f9 input=563b9a1ddd4facc3]*/
762762
{
763-
size_t zstd_ret;
764-
765763
// Error occured while converting argument, should be unreachable
766764
assert(size != ZSTD_CONTENTSIZE_ERROR);
767765

@@ -778,7 +776,7 @@ _zstd_ZstdCompressor_set_pledged_input_size_impl(ZstdCompressor *self,
778776
}
779777

780778
/* Set pledged content size */
781-
zstd_ret = ZSTD_CCtx_setPledgedSrcSize(self->cctx, size);
779+
size_t zstd_ret = ZSTD_CCtx_setPledgedSrcSize(self->cctx, size);
782780
PyMutex_Unlock(&self->lock);
783781
if (ZSTD_isError(zstd_ret)) {
784782
_zstd_state* mod_state = PyType_GetModuleState(Py_TYPE(self));

0 commit comments

Comments
 (0)