Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[3.14] gh-132983: Slightly tweak error messages for _zstd compressor/decompressor options dict (GH-134601)#134602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
gpshead merged 1 commit intopython:3.14frommiss-islington:backport-f478331-3.14
May 23, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletionsLib/test/test_zstd.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1424,11 +1424,12 @@ def test_init_bad_mode(self):
withself.assertRaises(ValueError):
ZstdFile(io.BytesIO(COMPRESSED_100_PLUS_32KB),"rw")

withself.assertRaisesRegex(TypeError,r"NOT be CompressionParameter"):
withself.assertRaisesRegex(TypeError,
r"NOT be a CompressionParameter"):
ZstdFile(io.BytesIO(),'rb',
options={CompressionParameter.compression_level:5})
withself.assertRaisesRegex(TypeError,
r"NOT be DecompressionParameter"):
r"NOT beaDecompressionParameter"):
ZstdFile(io.BytesIO(),'wb',
options={DecompressionParameter.window_log_max:21})

Expand Down
11 changes: 5 additions & 6 deletionsModules/_zstd/compressor.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -93,24 +93,23 @@ _zstd_set_c_parameters(ZstdCompressor *self, PyObject *level_or_options,
/* Check key type */
if (Py_TYPE(key) == mod_state->DParameter_type) {
PyErr_SetString(PyExc_TypeError,
"Key of compressionoption dict should "
"NOT be DecompressionParameter.");
"Key of compressionoptions dict should "
"NOT beaDecompressionParameter attribute.");
return -1;
}

int key_v = PyLong_AsInt(key);
if (key_v == -1 && PyErr_Occurred()) {
PyErr_SetString(PyExc_ValueError,
"Key of options dict should be a CompressionParameter attribute.");
"Key of options dict should be either a "
"CompressionParameter attribute or an int.");
return -1;
}

// TODO(emmatyping): check bounds when there is a value error here for better
// error message?
int value_v = PyLong_AsInt(value);
if (value_v == -1 && PyErr_Occurred()) {
PyErr_SetString(PyExc_ValueError,
"Value ofoption dict should be an int.");
"Value ofoptions dict should be an int.");
return -1;
}

Expand Down
7 changes: 3 additions & 4 deletionsModules/_zstd/decompressor.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -112,20 +112,19 @@ _zstd_set_d_parameters(ZstdDecompressor *self, PyObject *options)
if (Py_TYPE(key) == mod_state->CParameter_type) {
PyErr_SetString(PyExc_TypeError,
"Key of decompression options dict should "
"NOT be CompressionParameter.");
"NOT beaCompressionParameter attribute.");
return -1;
}

/* Both key & value should be 32-bit signed int */
int key_v = PyLong_AsInt(key);
if (key_v == -1 && PyErr_Occurred()) {
PyErr_SetString(PyExc_ValueError,
"Key of options dict should be a DecompressionParameter attribute.");
"Key of options dict should be either a "
"DecompressionParameter attribute or an int.");
return -1;
}

// TODO(emmatyping): check bounds when there is a value error here for better
// error message?
int value_v = PyLong_AsInt(value);
if (value_v == -1 && PyErr_Occurred()) {
PyErr_SetString(PyExc_ValueError,
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp