Skip to content

Commit 7f4c31b

Browse files
committed
feat: update code from upstream 3.14.6
1 parent 63fd605 commit 7f4c31b

14 files changed

Lines changed: 409 additions & 233 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/), and this project
66
adheres to [Semantic Versioning](https://semver.org/).
77

8+
## Unreleased
9+
10+
### :rocket: Added
11+
12+
- Update code with CPython 3.14.6 version
13+
814
## [1.5.0] - 2026-05-11
915

1016
[1.5.0]: https://github.com/rogdham/backports.zstd/releases/tag/v1.5.0

src/c/compression_zstd/clinic/compressor.c.h

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ PyDoc_STRVAR(_zstd_ZstdCompressor_new__doc__,
1717
" zstd_dict\n"
1818
" A ZstdDict object, a pre-trained Zstandard dictionary.\n"
1919
"\n"
20-
"Thread-safe at method level. For one-shot compression, use the compress()\n"
21-
"function instead.");
20+
"Thread-safe at method level. For one-shot compression, use the\n"
21+
"compress() function instead.");
2222

2323
static PyObject *
2424
_zstd_ZstdCompressor_new_impl(PyTypeObject *type, PyObject *level,
@@ -101,9 +101,9 @@ PyDoc_STRVAR(_zstd_ZstdCompressor_compress__doc__,
101101
" Can be these 3 values ZstdCompressor.CONTINUE,\n"
102102
" ZstdCompressor.FLUSH_BLOCK, ZstdCompressor.FLUSH_FRAME\n"
103103
"\n"
104-
"Return a chunk of compressed data if possible, or b\'\' otherwise. When you have\n"
105-
"finished providing data to the compressor, call the flush() method to finish\n"
106-
"the compression process.");
104+
"Return a chunk of compressed data if possible, or b\'\' otherwise.\n"
105+
"When you have finished providing data to the compressor, call the\n"
106+
"flush() method to finish the compression process.");
107107

108108
#define _ZSTD_ZSTDCOMPRESSOR_COMPRESS_METHODDEF \
109109
{"compress", _PyCFunction_CAST(_zstd_ZstdCompressor_compress), METH_FASTCALL|METH_KEYWORDS, _zstd_ZstdCompressor_compress__doc__},
@@ -185,9 +185,9 @@ PyDoc_STRVAR(_zstd_ZstdCompressor_flush__doc__,
185185
" Can be these 2 values ZstdCompressor.FLUSH_FRAME,\n"
186186
" ZstdCompressor.FLUSH_BLOCK\n"
187187
"\n"
188-
"Flush any remaining data left in internal buffers. Since Zstandard data\n"
189-
"consists of one or more independent frames, the compressor object can still\n"
190-
"be used after this method is called.");
188+
"Flush any remaining data left in internal buffers. Since Zstandard\n"
189+
"data consists of one or more independent frames, the compressor\n"
190+
"object can still be used after this method is called.");
191191

192192
#define _ZSTD_ZSTDCOMPRESSOR_FLUSH_METHODDEF \
193193
{"flush", _PyCFunction_CAST(_zstd_ZstdCompressor_flush), METH_FASTCALL|METH_KEYWORDS, _zstd_ZstdCompressor_flush__doc__},
@@ -258,13 +258,14 @@ PyDoc_STRVAR(_zstd_ZstdCompressor_set_pledged_input_size__doc__,
258258
" size\n"
259259
" The size of the uncompressed data to be provided to the compressor.\n"
260260
"\n"
261-
"This method can be used to ensure the header of the frame about to be written\n"
262-
"includes the size of the data, unless the CompressionParameter.content_size_flag\n"
263-
"is set to False. If last_mode != FLUSH_FRAME, then a RuntimeError is raised.\n"
261+
"This method can be used to ensure the header of the frame about to\n"
262+
"be written includes the size of the data, unless the\n"
263+
"CompressionParameter.content_size_flag is set to False.\n"
264+
"If last_mode != FLUSH_FRAME, then a RuntimeError is raised.\n"
264265
"\n"
265-
"It is important to ensure that the pledged data size matches the actual data\n"
266-
"size. If they do not match the compressed output data may be corrupted and the\n"
267-
"final chunk written may be lost.");
266+
"It is important to ensure that the pledged data size matches the\n"
267+
"actual data size. If they do not match the compressed output data\n"
268+
"may be corrupted and the final chunk written may be lost.");
268269

269270
#define _ZSTD_ZSTDCOMPRESSOR_SET_PLEDGED_INPUT_SIZE_METHODDEF \
270271
{"set_pledged_input_size", (PyCFunction)_zstd_ZstdCompressor_set_pledged_input_size, METH_O, _zstd_ZstdCompressor_set_pledged_input_size__doc__},
@@ -287,4 +288,4 @@ _zstd_ZstdCompressor_set_pledged_input_size(PyObject *self, PyObject *arg)
287288
exit:
288289
return return_value;
289290
}
290-
/*[clinic end generated code: output=c1d5c2cf06a8becd input=a9049054013a1b77]*/
291+
/*[clinic end generated code: output=1a5e21476885866c input=a9049054013a1b77]*/

src/c/compression_zstd/clinic/decompressor.c.h

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ PyDoc_STRVAR(_zstd_ZstdDecompressor_new__doc__,
1515
" options\n"
1616
" A dict object that contains advanced decompression parameters.\n"
1717
"\n"
18-
"Thread-safe at method level. For one-shot decompression, use the decompress()\n"
19-
"function instead.");
18+
"Thread-safe at method level. For one-shot decompression, use the\n"
19+
"decompress() function instead.");
2020

2121
static PyObject *
2222
_zstd_ZstdDecompressor_new_impl(PyTypeObject *type, PyObject *zstd_dict,
@@ -86,7 +86,8 @@ PyDoc_STRVAR(_zstd_ZstdDecompressor_unused_data__doc__,
8686
"A bytes object of un-consumed input data.\n"
8787
"\n"
8888
"When ZstdDecompressor object stops after a frame is\n"
89-
"decompressed, unused input data after the frame. Otherwise this will be b\'\'.");
89+
"decompressed, unused input data after the frame. Otherwise this\n"
90+
"will be b\'\'.");
9091
#if defined(_zstd_ZstdDecompressor_unused_data_DOCSTR)
9192
# undef _zstd_ZstdDecompressor_unused_data_DOCSTR
9293
#endif
@@ -124,18 +125,19 @@ PyDoc_STRVAR(_zstd_ZstdDecompressor_decompress__doc__,
124125
" output buffer is unlimited. When it is nonnegative, returns at\n"
125126
" most max_length bytes of decompressed data.\n"
126127
"\n"
127-
"If *max_length* is nonnegative, returns at most *max_length* bytes of\n"
128-
"decompressed data. If this limit is reached and further output can be\n"
129-
"produced, *self.needs_input* will be set to ``False``. In this case, the next\n"
130-
"call to *decompress()* may provide *data* as b\'\' to obtain more of the output.\n"
128+
"If *max_length* is nonnegative, returns at most *max_length* bytes\n"
129+
"of decompressed data. If this limit is reached and further output\n"
130+
"can be produced, *self.needs_input* will be set to ``False``. In\n"
131+
"this case, the next call to *decompress()* may provide *data* as b\'\'\n"
132+
"to obtain more of the output.\n"
131133
"\n"
132-
"If all of the input data was decompressed and returned (either because this\n"
133-
"was less than *max_length* bytes, or because *max_length* was negative),\n"
134-
"*self.needs_input* will be set to True.\n"
134+
"If all of the input data was decompressed and returned (either\n"
135+
"because this was less than *max_length* bytes, or because\n"
136+
"*max_length* was negative), *self.needs_input* will be set to True.\n"
135137
"\n"
136-
"Attempting to decompress data after the end of a frame is reached raises an\n"
137-
"EOFError. Any data found after the end of the frame is ignored and saved in\n"
138-
"the self.unused_data attribute.");
138+
"Attempting to decompress data after the end of a frame is reached\n"
139+
"raises an EOFError. Any data found after the end of the frame is\n"
140+
"ignored and saved in the self.unused_data attribute.");
139141

140142
#define _ZSTD_ZSTDDECOMPRESSOR_DECOMPRESS_METHODDEF \
141143
{"decompress", _PyCFunction_CAST(_zstd_ZstdDecompressor_decompress), METH_FASTCALL|METH_KEYWORDS, _zstd_ZstdDecompressor_decompress__doc__},
@@ -215,4 +217,4 @@ _zstd_ZstdDecompressor_decompress(PyObject *self, PyObject *const *args, Py_ssiz
215217

216218
return return_value;
217219
}
218-
/*[clinic end generated code: output=30c12ef047027ede input=a9049054013a1b77]*/
220+
/*[clinic end generated code: output=70bc308e86463751 input=a9049054013a1b77]*/

src/c/compression_zstd/clinic/zstddict.c.h

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ PyDoc_STRVAR(_zstd_ZstdDict_new__doc__,
1717
" advanced cases. Otherwise, check that the content represents\n"
1818
" a Zstandard dictionary created by the zstd library or CLI.\n"
1919
"\n"
20-
"The dictionary can be used for compression or decompression, and can be shared\n"
21-
"by multiple ZstdCompressor or ZstdDecompressor objects.");
20+
"The dictionary can be used for compression or decompression, and can be\n"
21+
"shared by multiple ZstdCompressor or ZstdDecompressor objects.");
2222

2323
static PyObject *
2424
_zstd_ZstdDict_new_impl(PyTypeObject *type, Py_buffer *dict_content,
@@ -121,11 +121,11 @@ PyDoc_STRVAR(_zstd_ZstdDict_as_digested_dict__doc__,
121121
"Pass this attribute as zstd_dict argument:\n"
122122
"compress(dat, zstd_dict=zd.as_digested_dict)\n"
123123
"\n"
124-
"1. Some advanced compression parameters of compressor may be overridden\n"
125-
" by parameters of digested dictionary.\n"
126-
"2. ZstdDict has a digested dictionaries cache for each compression level.\n"
127-
" It\'s faster when loading again a digested dictionary with the same\n"
128-
" compression level.\n"
124+
"1. Some advanced compression parameters of compressor may be\n"
125+
" overridden by parameters of digested dictionary.\n"
126+
"2. ZstdDict has a digested dictionaries cache for each compression\n"
127+
" level. It\'s faster when loading again a digested dictionary with\n"
128+
" the same compression level.\n"
129129
"3. No need to use this for decompression.");
130130
#if defined(_zstd_ZstdDict_as_digested_dict_DOCSTR)
131131
# undef _zstd_ZstdDict_as_digested_dict_DOCSTR
@@ -157,9 +157,10 @@ PyDoc_STRVAR(_zstd_ZstdDict_as_undigested_dict__doc__,
157157
"Pass this attribute as zstd_dict argument:\n"
158158
"compress(dat, zstd_dict=zd.as_undigested_dict)\n"
159159
"\n"
160-
"1. The advanced compression parameters of compressor will not be overridden.\n"
161-
"2. Loading an undigested dictionary is costly. If load an undigested dictionary\n"
162-
" multiple times, consider reusing a compressor object.\n"
160+
"1. The advanced compression parameters of compressor will not be\n"
161+
" overridden.\n"
162+
"2. Loading an undigested dictionary is costly. If load an undigested\n"
163+
" dictionary multiple times, consider reusing a compressor object.\n"
163164
"3. No need to use this for decompression.");
164165
#if defined(_zstd_ZstdDict_as_undigested_dict_DOCSTR)
165166
# undef _zstd_ZstdDict_as_undigested_dict_DOCSTR
@@ -191,9 +192,10 @@ PyDoc_STRVAR(_zstd_ZstdDict_as_prefix__doc__,
191192
"Pass this attribute as zstd_dict argument:\n"
192193
"compress(dat, zstd_dict=zd.as_prefix)\n"
193194
"\n"
194-
"1. Prefix is compatible with long distance matching, while dictionary is not.\n"
195-
"2. It only works for the first frame, then the compressor/decompressor will\n"
196-
" return to no prefix state.\n"
195+
"1. Prefix is compatible with long distance matching, while\n"
196+
" dictionary is not.\n"
197+
"2. It only works for the first frame, then the\n"
198+
" compressor/decompressor will return to no prefix state.\n"
197199
"3. When decompressing, must use the same prefix as when compressing.");
198200
#if defined(_zstd_ZstdDict_as_prefix_DOCSTR)
199201
# undef _zstd_ZstdDict_as_prefix_DOCSTR
@@ -218,4 +220,4 @@ _zstd_ZstdDict_as_prefix_get(PyObject *self, void *Py_UNUSED(context))
218220
{
219221
return _zstd_ZstdDict_as_prefix_get_impl((ZstdDict *)self);
220222
}
221-
/*[clinic end generated code: output=f41d9e2e2cc2928f input=a9049054013a1b77]*/
223+
/*[clinic end generated code: output=49b66061b4fcdb5f input=a9049054013a1b77]*/

src/c/compression_zstd/compressor.c

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,14 @@ _zstd.ZstdCompressor.__new__ as _zstd_ZstdCompressor_new
334334
335335
Create a compressor object for compressing data incrementally.
336336
337-
Thread-safe at method level. For one-shot compression, use the compress()
338-
function instead.
337+
Thread-safe at method level. For one-shot compression, use the
338+
compress() function instead.
339339
[clinic start generated code]*/
340340

341341
static PyObject *
342342
_zstd_ZstdCompressor_new_impl(PyTypeObject *type, PyObject *level,
343343
PyObject *options, PyObject *zstd_dict)
344-
/*[clinic end generated code: output=cdef61eafecac3d7 input=92de0211ae20ffdc]*/
344+
/*[clinic end generated code: output=cdef61eafecac3d7 input=bbfeeaa06fd3bd4d]*/
345345
{
346346
ZstdCompressor* self = PyObject_GC_New(ZstdCompressor, type);
347347
if (self == NULL) {
@@ -603,15 +603,15 @@ _zstd.ZstdCompressor.compress
603603
604604
Provide data to the compressor object.
605605
606-
Return a chunk of compressed data if possible, or b'' otherwise. When you have
607-
finished providing data to the compressor, call the flush() method to finish
608-
the compression process.
606+
Return a chunk of compressed data if possible, or b'' otherwise.
607+
When you have finished providing data to the compressor, call the
608+
flush() method to finish the compression process.
609609
[clinic start generated code]*/
610610

611611
static PyObject *
612612
_zstd_ZstdCompressor_compress_impl(ZstdCompressor *self, Py_buffer *data,
613613
int mode)
614-
/*[clinic end generated code: output=ed7982d1cf7b4f98 input=ac2c21d180f579ea]*/
614+
/*[clinic end generated code: output=ed7982d1cf7b4f98 input=11726dff64d7b2f9]*/
615615
{
616616
PyObject *ret;
617617

@@ -661,14 +661,14 @@ _zstd.ZstdCompressor.flush
661661
662662
Finish the compression process.
663663
664-
Flush any remaining data left in internal buffers. Since Zstandard data
665-
consists of one or more independent frames, the compressor object can still
666-
be used after this method is called.
664+
Flush any remaining data left in internal buffers. Since Zstandard
665+
data consists of one or more independent frames, the compressor
666+
object can still be used after this method is called.
667667
[clinic start generated code]*/
668668

669669
static PyObject *
670670
_zstd_ZstdCompressor_flush_impl(ZstdCompressor *self, int mode)
671-
/*[clinic end generated code: output=b7cf2c8d64dcf2e3 input=0ab19627f323cdbc]*/
671+
/*[clinic end generated code: output=b7cf2c8d64dcf2e3 input=130e0b1eddf0f498]*/
672672
{
673673
PyObject *ret;
674674

@@ -710,19 +710,20 @@ _zstd.ZstdCompressor.set_pledged_input_size
710710
711711
Set the uncompressed content size to be written into the frame header.
712712
713-
This method can be used to ensure the header of the frame about to be written
714-
includes the size of the data, unless the CompressionParameter.content_size_flag
715-
is set to False. If last_mode != FLUSH_FRAME, then a RuntimeError is raised.
713+
This method can be used to ensure the header of the frame about to
714+
be written includes the size of the data, unless the
715+
CompressionParameter.content_size_flag is set to False.
716+
If last_mode != FLUSH_FRAME, then a RuntimeError is raised.
716717
717-
It is important to ensure that the pledged data size matches the actual data
718-
size. If they do not match the compressed output data may be corrupted and the
719-
final chunk written may be lost.
718+
It is important to ensure that the pledged data size matches the
719+
actual data size. If they do not match the compressed output data
720+
may be corrupted and the final chunk written may be lost.
720721
[clinic start generated code]*/
721722

722723
static PyObject *
723724
_zstd_ZstdCompressor_set_pledged_input_size_impl(ZstdCompressor *self,
724725
unsigned long long size)
725-
/*[clinic end generated code: output=3a09e55cc0e3b4f9 input=afd8a7d78cff2eb5]*/
726+
/*[clinic end generated code: output=3a09e55cc0e3b4f9 input=d6d1669171af3da4]*/
726727
{
727728
// Error occured while converting argument, should be unreachable
728729
assert(size != ZSTD_CONTENTSIZE_ERROR);

src/c/compression_zstd/decompressor.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -480,14 +480,14 @@ _zstd.ZstdDecompressor.__new__ as _zstd_ZstdDecompressor_new
480480
481481
Create a decompressor object for decompressing data incrementally.
482482
483-
Thread-safe at method level. For one-shot decompression, use the decompress()
484-
function instead.
483+
Thread-safe at method level. For one-shot decompression, use the
484+
decompress() function instead.
485485
[clinic start generated code]*/
486486

487487
static PyObject *
488488
_zstd_ZstdDecompressor_new_impl(PyTypeObject *type, PyObject *zstd_dict,
489489
PyObject *options)
490-
/*[clinic end generated code: output=590ca65c1102ff4a input=213daa57e3ea4062]*/
490+
/*[clinic end generated code: output=590ca65c1102ff4a input=73879de69bf89f59]*/
491491
{
492492
ZstdDecompressor* self = PyObject_GC_New(ZstdDecompressor, type);
493493
if (self == NULL) {
@@ -587,12 +587,13 @@ _zstd.ZstdDecompressor.unused_data
587587
A bytes object of un-consumed input data.
588588
589589
When ZstdDecompressor object stops after a frame is
590-
decompressed, unused input data after the frame. Otherwise this will be b''.
590+
decompressed, unused input data after the frame. Otherwise this
591+
will be b''.
591592
[clinic start generated code]*/
592593

593594
static PyObject *
594595
_zstd_ZstdDecompressor_unused_data_get_impl(ZstdDecompressor *self)
595-
/*[clinic end generated code: output=f3a20940f11b6b09 input=54d41ecd681a3444]*/
596+
/*[clinic end generated code: output=f3a20940f11b6b09 input=0462065c5e60ba01]*/
596597
{
597598
PyObject *ret;
598599

@@ -632,25 +633,26 @@ _zstd.ZstdDecompressor.decompress
632633
633634
Decompress *data*, returning uncompressed bytes if possible, or b'' otherwise.
634635
635-
If *max_length* is nonnegative, returns at most *max_length* bytes of
636-
decompressed data. If this limit is reached and further output can be
637-
produced, *self.needs_input* will be set to ``False``. In this case, the next
638-
call to *decompress()* may provide *data* as b'' to obtain more of the output.
636+
If *max_length* is nonnegative, returns at most *max_length* bytes
637+
of decompressed data. If this limit is reached and further output
638+
can be produced, *self.needs_input* will be set to ``False``. In
639+
this case, the next call to *decompress()* may provide *data* as b''
640+
to obtain more of the output.
639641
640-
If all of the input data was decompressed and returned (either because this
641-
was less than *max_length* bytes, or because *max_length* was negative),
642-
*self.needs_input* will be set to True.
642+
If all of the input data was decompressed and returned (either
643+
because this was less than *max_length* bytes, or because
644+
*max_length* was negative), *self.needs_input* will be set to True.
643645
644-
Attempting to decompress data after the end of a frame is reached raises an
645-
EOFError. Any data found after the end of the frame is ignored and saved in
646-
the self.unused_data attribute.
646+
Attempting to decompress data after the end of a frame is reached
647+
raises an EOFError. Any data found after the end of the frame is
648+
ignored and saved in the self.unused_data attribute.
647649
[clinic start generated code]*/
648650

649651
static PyObject *
650652
_zstd_ZstdDecompressor_decompress_impl(ZstdDecompressor *self,
651653
Py_buffer *data,
652654
Py_ssize_t max_length)
653-
/*[clinic end generated code: output=a4302b3c940dbec6 input=6463dfdf98091caa]*/
655+
/*[clinic end generated code: output=a4302b3c940dbec6 input=b55991a007f4c558]*/
654656
{
655657
PyObject *ret;
656658
/* Thread-safe code */

0 commit comments

Comments
 (0)