Skip to content

Commit bb6c416

Browse files
committed
tweak comments
1 parent fe03b15 commit bb6c416

File tree

9 files changed

+70
-74
lines changed

9 files changed

+70
-74
lines changed

Lib/test/test_zstd.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ def test_unknown_compression_parameter(self):
288288
KEY = 100001234
289289
option = {CompressionParameter.compression_level: 10,
290290
KEY: 200000000}
291-
pattern = r'Zstd compression parameter.*?"unknown parameter \(key %d\)"' \
292-
% KEY
291+
pattern = (r'Invalid zstd compression parameter.*?'
292+
fr'"unknown parameter \(key {KEY}\)"')
293293
with self.assertRaisesRegex(ZstdError, pattern):
294294
ZstdCompressor(options=option)
295295

@@ -420,8 +420,8 @@ def test_unknown_decompression_parameter(self):
420420
KEY = 100001234
421421
options = {DecompressionParameter.window_log_max: DecompressionParameter.window_log_max.bounds()[1],
422422
KEY: 200000000}
423-
pattern = r'Zstd decompression parameter.*?"unknown parameter \(key %d\)"' \
424-
% KEY
423+
pattern = (r'Invalid zstd decompression parameter.*?'
424+
fr'"unknown parameter \(key {KEY}\)"')
425425
with self.assertRaisesRegex(ZstdError, pattern):
426426
ZstdDecompressor(options=options)
427427

Modules/_zstd/_zstdmodule.c

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ set_parameter_error(const _zstd_state* const state, int is_compress,
149149
}
150150
if (ZSTD_isError(bounds.error)) {
151151
PyErr_Format(state->ZstdError,
152-
"Zstd %s parameter \"%s\" is invalid.",
152+
"Invalid zstd %s parameter \"%s\".",
153153
type, name);
154154
return;
155155
}
@@ -184,13 +184,13 @@ _zstd.train_dict
184184
The size of the dictionary.
185185
/
186186
187-
Internal function, train a Zstandard dictionary on sample data.
187+
Train a Zstandard dictionary on sample data.
188188
[clinic start generated code]*/
189189

190190
static PyObject *
191191
_zstd_train_dict_impl(PyObject *module, PyBytesObject *samples_bytes,
192192
PyObject *samples_sizes, Py_ssize_t dict_size)
193-
/*[clinic end generated code: output=8e87fe43935e8f77 input=829e31fbbf3454b0]*/
193+
/*[clinic end generated code: output=8e87fe43935e8f77 input=d20dedb21c72cb62]*/
194194
{
195195
// TODO(emmatyping): The preamble and suffix to this function and _finalize_dict
196196
// are pretty similar. We should see if we can refactor them to share that code.
@@ -255,7 +255,7 @@ _zstd_train_dict_impl(PyObject *module, PyBytesObject *samples_bytes,
255255
chunk_sizes, (uint32_t)chunks_number);
256256
Py_END_ALLOW_THREADS
257257

258-
/* Check zstd dict error */
258+
/* Check Zstandard dict error */
259259
if (ZDICT_isError(zstd_ret)) {
260260
_zstd_state* const mod_state = get_zstd_state(module);
261261
set_zstd_error(mod_state, ERR_TRAIN_DICT, zstd_ret);
@@ -289,18 +289,18 @@ _zstd.finalize_dict
289289
dict_size: Py_ssize_t
290290
The size of the dictionary.
291291
compression_level: int
292-
Optimize for a specific zstd compression level, 0 means default.
292+
Optimize for a specific Zstandard compression level, 0 means default.
293293
/
294294
295-
Internal function, finalize a Zstandard dictionary.
295+
Finalize a Zstandard dictionary.
296296
[clinic start generated code]*/
297297

298298
static PyObject *
299299
_zstd_finalize_dict_impl(PyObject *module, PyBytesObject *custom_dict_bytes,
300300
PyBytesObject *samples_bytes,
301301
PyObject *samples_sizes, Py_ssize_t dict_size,
302302
int compression_level)
303-
/*[clinic end generated code: output=f91821ba5ae85bda input=11af97dcc7608059]*/
303+
/*[clinic end generated code: output=f91821ba5ae85bda input=3c7e2480aa08fb56]*/
304304
{
305305
Py_ssize_t chunks_number;
306306
size_t *chunk_sizes = NULL;
@@ -357,7 +357,7 @@ _zstd_finalize_dict_impl(PyObject *module, PyBytesObject *custom_dict_bytes,
357357

358358
/* Parameters */
359359

360-
/* Optimize for a specific zstd compression level, 0 means default. */
360+
/* Optimize for a specific Zstandard compression level, 0 means default. */
361361
params.compressionLevel = compression_level;
362362
/* Write log to stderr, 0 = none. */
363363
params.notificationLevel = 0;
@@ -373,7 +373,7 @@ _zstd_finalize_dict_impl(PyObject *module, PyBytesObject *custom_dict_bytes,
373373
(uint32_t)chunks_number, params);
374374
Py_END_ALLOW_THREADS
375375

376-
/* Check zstd dict error */
376+
/* Check Zstandard dict error */
377377
if (ZDICT_isError(zstd_ret)) {
378378
_zstd_state* const mod_state = get_zstd_state(module);
379379
set_zstd_error(mod_state, ERR_FINALIZE_DICT, zstd_ret);
@@ -404,12 +404,12 @@ _zstd.get_param_bounds
404404
is_compress: bool
405405
True for CompressionParameter, False for DecompressionParameter.
406406
407-
Internal function, get CompressionParameter/DecompressionParameter bounds.
407+
Get CompressionParameter/DecompressionParameter bounds.
408408
[clinic start generated code]*/
409409

410410
static PyObject *
411411
_zstd_get_param_bounds_impl(PyObject *module, int parameter, int is_compress)
412-
/*[clinic end generated code: output=4acf5a876f0620ca input=84e669591e487008]*/
412+
/*[clinic end generated code: output=4acf5a876f0620ca input=45742ef0a3531b65]*/
413413
{
414414
ZSTD_bounds bound;
415415
if (is_compress) {
@@ -439,14 +439,12 @@ _zstd.get_frame_size
439439
A bytes-like object, it should start from the beginning of a frame,
440440
and contains at least one complete frame.
441441
442-
Get the size of a zstd frame, including frame header and 4-byte checksum if it has one.
443-
444-
It will iterate all blocks' headers within a frame, to accumulate the frame size.
442+
Get the size of a Zstandard frame, including the header and optional checksum.
445443
[clinic start generated code]*/
446444

447445
static PyObject *
448446
_zstd_get_frame_size_impl(PyObject *module, Py_buffer *frame_buffer)
449-
/*[clinic end generated code: output=a7384c2f8780f442 input=7d3ad24311893bf3]*/
447+
/*[clinic end generated code: output=a7384c2f8780f442 input=3b9f73f8c8129d38]*/
450448
{
451449
size_t frame_size;
452450

@@ -469,14 +467,14 @@ _zstd_get_frame_size_impl(PyObject *module, Py_buffer *frame_buffer)
469467
_zstd.get_frame_info
470468
471469
frame_buffer: Py_buffer
472-
A bytes-like object, containing the header of a zstd frame.
470+
A bytes-like object, containing the header of a Zstandard frame.
473471
474-
Internal function, get zstd frame infomation from a frame header.
472+
Get Zstandard frame infomation from a frame header.
475473
[clinic start generated code]*/
476474

477475
static PyObject *
478476
_zstd_get_frame_info_impl(PyObject *module, Py_buffer *frame_buffer)
479-
/*[clinic end generated code: output=56e033cf48001929 input=1816f14656b6aa22]*/
477+
/*[clinic end generated code: output=56e033cf48001929 input=94b240583ae22ca5]*/
480478
{
481479
uint64_t decompressed_size;
482480
uint32_t dict_id;
@@ -515,13 +513,13 @@ _zstd.set_parameter_types
515513
d_parameter_type: object(subclass_of='&PyType_Type')
516514
DecompressionParameter IntEnum type object
517515
518-
Internal function, set CompressionParameter/DecompressionParameter types for validity check.
516+
Set CompressionParameter and DecompressionParameter types for validity check.
519517
[clinic start generated code]*/
520518

521519
static PyObject *
522520
_zstd_set_parameter_types_impl(PyObject *module, PyObject *c_parameter_type,
523521
PyObject *d_parameter_type)
524-
/*[clinic end generated code: output=f3313b1294f19502 input=30402523871b8280]*/
522+
/*[clinic end generated code: output=f3313b1294f19502 input=75d7a953580fae5f]*/
525523
{
526524
_zstd_state* const mod_state = get_zstd_state(module);
527525

Modules/_zstd/clinic/_zstdmodule.c.h

Lines changed: 10 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_zstd/clinic/compressor.c.h

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_zstd/clinic/decompressor.c.h

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_zstd/clinic/zstddict.c.h

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_zstd/compressor.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ _zstd_set_c_parameters(ZstdCompressor *self, PyObject *level_or_options,
115115
self->compression_level = value_v;
116116
}
117117
else if (key_v == ZSTD_c_nbWorkers) {
118-
/* From zstd library doc:
118+
/* From the zstd library docs:
119119
1. When nbWorkers >= 1, triggers asynchronous mode when
120120
used with ZSTD_compressStream2().
121121
2, Default value is `0`, aka "single-threaded mode" : no
@@ -319,7 +319,7 @@ _zstd.ZstdCompressor.__new__ as _zstd_ZstdCompressor_new
319319
options: object = None
320320
A dict object that contains advanced compression parameters.
321321
zstd_dict: object = None
322-
A ZstdDict object, a pre-trained zstd dictionary.
322+
A ZstdDict object, a pre-trained Zstandard dictionary.
323323
324324
Create a compressor object for compressing data incrementally.
325325
@@ -330,7 +330,7 @@ function instead.
330330
static PyObject *
331331
_zstd_ZstdCompressor_new_impl(PyTypeObject *type, PyObject *level,
332332
PyObject *options, PyObject *zstd_dict)
333-
/*[clinic end generated code: output=cdef61eafecac3d7 input=b9ea61ecafbb1b1e]*/
333+
/*[clinic end generated code: output=cdef61eafecac3d7 input=92de0211ae20ffdc]*/
334334
{
335335
ZstdCompressor* self = PyObject_GC_New(ZstdCompressor, type);
336336
if (self == NULL) {
@@ -371,7 +371,7 @@ _zstd_ZstdCompressor_new_impl(PyTypeObject *type, PyObject *level,
371371
}
372372
}
373373

374-
/* Load zstd dictionary to compression context */
374+
/* Load Zstandard dictionary to compression context */
375375
self->dict = NULL;
376376
if (zstd_dict != Py_None) {
377377
if (_zstd_load_c_dict(self, zstd_dict) < 0) {
@@ -446,7 +446,7 @@ compress_impl(ZstdCompressor *self, Py_buffer *data,
446446
}
447447

448448

449-
/* zstd stream compress */
449+
/* Zstandard stream compress */
450450
while (1) {
451451
Py_BEGIN_ALLOW_THREADS
452452
zstd_ret = ZSTD_compressStream2(self->cctx, &out, &in, end_directive);
@@ -510,7 +510,7 @@ compress_mt_continue_impl(ZstdCompressor *self, Py_buffer *data)
510510
goto error;
511511
}
512512

513-
/* zstd stream compress */
513+
/* Zstandard stream compress */
514514
while (1) {
515515
Py_BEGIN_ALLOW_THREADS
516516
do {
@@ -619,14 +619,14 @@ _zstd.ZstdCompressor.flush
619619
620620
Finish the compression process.
621621
622-
Flush any remaining data left in internal buffers. Since zstd data consists
623-
of one or more independent frames, the compressor object can still be used
624-
after this method is called.
622+
Flush any remaining data left in internal buffers. Since Zstandard data
623+
consists of one or more independent frames, the compressor object can still
624+
be used after this method is called.
625625
[clinic start generated code]*/
626626

627627
static PyObject *
628628
_zstd_ZstdCompressor_flush_impl(ZstdCompressor *self, int mode)
629-
/*[clinic end generated code: output=b7cf2c8d64dcf2e3 input=a766870301932b85]*/
629+
/*[clinic end generated code: output=b7cf2c8d64dcf2e3 input=0ab19627f323cdbc]*/
630630
{
631631
PyObject *ret;
632632

0 commit comments

Comments
 (0)