Skip to content

Commit 4cc2d4e

Browse files
committed
Consistently use Zstandard vs zstd
1 parent 15fc9ce commit 4cc2d4e

File tree

9 files changed

+39
-63
lines changed

9 files changed

+39
-63
lines changed

Lib/test/test_zstd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,9 +1072,9 @@ def test_invalid_dict(self):
10721072

10731073
# corrupted
10741074
zd = ZstdDict(dict_content, is_raw=False)
1075-
with self.assertRaisesRegex(ZstdError, r'ZSTD_CDict.*?corrupted'):
1075+
with self.assertRaisesRegex(ZstdError, r'ZSTD_CDict.*?content\.$'):
10761076
ZstdCompressor(zstd_dict=zd.as_digested_dict)
1077-
with self.assertRaisesRegex(ZstdError, r'ZSTD_DDict.*?corrupted'):
1077+
with self.assertRaisesRegex(ZstdError, r'ZSTD_DDict.*?content\.$'):
10781078
ZstdDecompressor(zd)
10791079

10801080
# wrong type

Modules/_zstd/_zstdmodule.c

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
/*
2-
Low level interface to Meta's zstd library for use in the compression.zstd
3-
Python module.
4-
*/
1+
/* Low level interface to the Zstandard algorthm & the zstd library. */
52

63
#ifndef Py_BUILD_CORE_BUILTIN
74
# define Py_BUILD_CORE_MODULE 1
@@ -34,17 +31,17 @@ set_zstd_error(const _zstd_state* const state,
3431
switch (type)
3532
{
3633
case ERR_DECOMPRESS:
37-
msg = "Unable to decompress zstd data: %s";
34+
msg = "Unable to decompress Zstandard data: %s";
3835
break;
3936
case ERR_COMPRESS:
40-
msg = "Unable to compress zstd data: %s";
37+
msg = "Unable to compress Zstandard data: %s";
4138
break;
4239

4340
case ERR_LOAD_D_DICT:
44-
msg = "Unable to load zstd dictionary or prefix for decompression: %s";
41+
msg = "Unable to load Zstandard dictionary or prefix for decompression: %s";
4542
break;
4643
case ERR_LOAD_C_DICT:
47-
msg = "Unable to load zstd dictionary or prefix for compression: %s";
44+
msg = "Unable to load Zstandard dictionary or prefix for compression: %s";
4845
break;
4946

5047
case ERR_GET_C_BOUNDS:
@@ -58,10 +55,10 @@ set_zstd_error(const _zstd_state* const state,
5855
break;
5956

6057
case ERR_TRAIN_DICT:
61-
msg = "Unable to train zstd dictionary: %s";
58+
msg = "Unable to train the Zstandard dictionary: %s";
6259
break;
6360
case ERR_FINALIZE_DICT:
64-
msg = "Unable to finalize zstd dictionary: %s";
61+
msg = "Unable to finalize the Zstandard dictionary: %s";
6562
break;
6663

6764
default:
@@ -187,13 +184,13 @@ _zstd.train_dict
187184
The size of the dictionary.
188185
/
189186
190-
Internal function, train a zstd dictionary on sample data.
187+
Internal function, train a Zstandard dictionary on sample data.
191188
[clinic start generated code]*/
192189

193190
static PyObject *
194191
_zstd_train_dict_impl(PyObject *module, PyBytesObject *samples_bytes,
195192
PyObject *samples_sizes, Py_ssize_t dict_size)
196-
/*[clinic end generated code: output=8e87fe43935e8f77 input=70fcd8937f2528b6]*/
193+
/*[clinic end generated code: output=8e87fe43935e8f77 input=829e31fbbf3454b0]*/
197194
{
198195
// TODO(emmatyping): The preamble and suffix to this function and _finalize_dict
199196
// are pretty similar. We should see if we can refactor them to share that code.
@@ -295,15 +292,15 @@ _zstd.finalize_dict
295292
Optimize for a specific zstd compression level, 0 means default.
296293
/
297294
298-
Internal function, finalize a zstd dictionary.
295+
Internal function, finalize a Zstandard dictionary.
299296
[clinic start generated code]*/
300297

301298
static PyObject *
302299
_zstd_finalize_dict_impl(PyObject *module, PyBytesObject *custom_dict_bytes,
303300
PyBytesObject *samples_bytes,
304301
PyObject *samples_sizes, Py_ssize_t dict_size,
305302
int compression_level)
306-
/*[clinic end generated code: output=f91821ba5ae85bda input=130d1508adb55ba1]*/
303+
/*[clinic end generated code: output=f91821ba5ae85bda input=11af97dcc7608059]*/
307304
{
308305
Py_ssize_t chunks_number;
309306
size_t *chunk_sizes = NULL;
@@ -457,9 +454,9 @@ _zstd_get_frame_size_impl(PyObject *module, Py_buffer *frame_buffer)
457454
if (ZSTD_isError(frame_size)) {
458455
_zstd_state* const mod_state = get_zstd_state(module);
459456
PyErr_Format(mod_state->ZstdError,
460-
"Error when finding the compressed size of a zstd frame. "
461-
"Make sure the frame_buffer argument starts from the "
462-
"beginning of a frame, and its length not less than this "
457+
"Error when finding the compressed size of a Zstandard frame. "
458+
"Ensure the frame_buffer argument starts from the "
459+
"beginning of a frame, and its length is not less than this "
463460
"complete frame. Zstd error message: %s.",
464461
ZSTD_getErrorName(frame_size));
465462
return NULL;
@@ -494,9 +491,9 @@ _zstd_get_frame_info_impl(PyObject *module, Py_buffer *frame_buffer)
494491
_zstd_state* const mod_state = get_zstd_state(module);
495492
PyErr_SetString(mod_state->ZstdError,
496493
"Error when getting information from the header of "
497-
"a zstd frame. Make sure the frame_buffer argument "
494+
"a Zstandard frame. Ensure the frame_buffer argument "
498495
"starts from the beginning of a frame, and its length "
499-
"not less than the frame header (6~18 bytes).");
496+
"is not less than the frame header (6~18 bytes).");
500497
return NULL;
501498
}
502499

Modules/_zstd/_zstdmodule.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
/*
2-
Low level interface to Meta's zstd library for use in the compression.zstd
3-
Python module.
4-
*/
1+
/* Low level interface to the Zstandard algorthm & the zstd library. */
52

63
/* Declarations shared between different parts of the _zstd module*/
74

Modules/_zstd/buffer.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
/*
2-
Low level interface to Meta's zstd library for use in the compression.zstd
3-
Python module.
4-
*/
1+
/* Low level interface to the Zstandard algorthm & the zstd library. */
52

63
#ifndef ZSTD_BUFFER_H
74
#define ZSTD_BUFFER_H

Modules/_zstd/clinic/_zstdmodule.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/compressor.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
/*
2-
Low level interface to Meta's zstd library for use in the compression.zstd
3-
Python module.
4-
*/
1+
/* Low level interface to the Zstandard algorthm & the zstd library. */
52

63
/* ZstdCompressor class definitions */
74

@@ -186,8 +183,8 @@ _get_CDict(ZstdDict *self, int compressionLevel)
186183
_zstd_state* const mod_state = PyType_GetModuleState(Py_TYPE(self));
187184
if (mod_state != NULL) {
188185
PyErr_SetString(mod_state->ZstdError,
189-
"Failed to create ZSTD_CDict instance from zstd "
190-
"dictionary content. Maybe the content is corrupted.");
186+
"Failed to create a ZSTD_CDict instance from "
187+
"Zstandard dictionary content.");
191188
}
192189
goto error;
193190
}

Modules/_zstd/decompressor.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
/*
2-
Low level interface to Meta's zstd library for use in the compression.zstd
3-
Python module.
4-
*/
1+
/* Low level interface to the Zstandard algorthm & the zstd library. */
52

63
/* ZstdDecompressor class definition */
74

@@ -78,8 +75,8 @@ _get_DDict(ZstdDict *self)
7875
_zstd_state* const mod_state = PyType_GetModuleState(Py_TYPE(self));
7976
if (mod_state != NULL) {
8077
PyErr_SetString(mod_state->ZstdError,
81-
"Failed to create ZSTD_DDict instance from zstd "
82-
"dictionary content. Maybe the content is corrupted.");
78+
"Failed to create a ZSTD_DDict instance from "
79+
"Zstandard dictionary content.");
8380
}
8481
}
8582
}
@@ -370,7 +367,7 @@ stream_decompress(ZstdDecompressor *self, Py_buffer *data, Py_ssize_t max_length
370367

371368
/* Check .eof flag */
372369
if (self->eof) {
373-
PyErr_SetString(PyExc_EOFError, "Already at the end of a zstd frame.");
370+
PyErr_SetString(PyExc_EOFError, "Already at the end of a Zstandard frame.");
374371
assert(ret == NULL);
375372
return NULL;
376373
}

Modules/_zstd/zstddict.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
/*
2-
Low level interface to Meta's zstd library for use in the compression.zstd
3-
Python module.
4-
*/
1+
/* Low level interface to the Zstandard algorthm & the zstd library. */
52

63
/* ZstdDict class definitions */
74

@@ -84,9 +81,7 @@ _zstd_ZstdDict_new_impl(PyTypeObject *type, PyObject *dict_content,
8481

8582
/* Check validity for ordinary dictionary */
8683
if (!is_raw && self->dict_id == 0) {
87-
char *msg = "The dict_content argument is not a valid zstd "
88-
"dictionary. The first 4 bytes of a valid zstd dictionary "
89-
"should be a magic number: b'\\x37\\xA4\\x30\\xEC'.\n";
84+
char *msg = "Invalid Zstandard dictionary and is_raw not set.\n";
9085
PyErr_SetString(PyExc_ValueError, msg);
9186
goto error;
9287
}
@@ -123,15 +118,14 @@ ZstdDict_dealloc(PyObject *ob)
123118
}
124119

125120
PyDoc_STRVAR(ZstdDict_dictid_doc,
126-
"ID of zstd dictionary, a 32-bit unsigned int value.\n\n"
127-
"Non-zero means ordinary dictionary, was created by zstd functions, follow\n"
128-
"a specified format.\n\n"
129-
"0 means a \"raw content\" dictionary, free of any format restriction, used\n"
130-
"for advanced user.");
121+
"The ID of Zstandard dictionary, an integer between 0 and 2**32.\n\n"
122+
"A non-zero value represents an ordinary Zstandard dictionary, "
123+
"conforming to the standardised format.\n\n"
124+
"The special value '0' means a 'raw content' dictionary,"
125+
"without any restrictions on format or content.");
131126

132127
PyDoc_STRVAR(ZstdDict_dictcontent_doc,
133-
"The content of zstd dictionary, a bytes object, it's the same as dict_content\n"
134-
"argument in ZstdDict.__init__() method. It can be used with other programs.");
128+
"The content of a Zstandard dictionary, as a bytes object.");
135129

136130
static PyObject *
137131
ZstdDict_str(PyObject *ob)

Modules/_zstd/zstddict.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
/*
2-
Low level interface to Meta's zstd library for use in the compression.zstd
3-
Python module.
4-
*/
1+
/* Low level interface to the Zstandard algorthm & the zstd library. */
52

63
#ifndef ZSTD_DICT_H
74
#define ZSTD_DICT_H

0 commit comments

Comments
 (0)