File tree Expand file tree Collapse file tree 3 files changed +11
-12
lines changed
Filter options
Expand file tree Collapse file tree 3 files changed +11
-12
lines changed
Original file line number Diff line number Diff line change @@ -1424,11 +1424,12 @@ def test_init_bad_mode(self):
1424
1424
with self .assertRaises (ValueError ):
1425
1425
ZstdFile (io .BytesIO (COMPRESSED_100_PLUS_32KB ), "rw" )
1426
1426
1427
- with self .assertRaisesRegex (TypeError , r"NOT be CompressionParameter" ):
1427
+ with self .assertRaisesRegex (TypeError ,
1428
+ r"NOT be a CompressionParameter" ):
1428
1429
ZstdFile (io .BytesIO (), 'rb' ,
1429
1430
options = {CompressionParameter .compression_level :5 })
1430
1431
with self .assertRaisesRegex (TypeError ,
1431
- r"NOT be DecompressionParameter" ):
1432
+ r"NOT be a DecompressionParameter" ):
1432
1433
ZstdFile (io .BytesIO (), 'wb' ,
1433
1434
options = {DecompressionParameter .window_log_max :21 })
1434
1435
Original file line number Diff line number Diff line change @@ -93,24 +93,23 @@ _zstd_set_c_parameters(ZstdCompressor *self, PyObject *level_or_options,
93
93
/* Check key type */
94
94
if (Py_TYPE (key ) == mod_state -> DParameter_type ) {
95
95
PyErr_SetString (PyExc_TypeError ,
96
- "Key of compression option dict should "
97
- "NOT be DecompressionParameter." );
96
+ "Key of compression options dict should "
97
+ "NOT be a DecompressionParameter attribute ." );
98
98
return -1 ;
99
99
}
100
100
101
101
int key_v = PyLong_AsInt (key );
102
102
if (key_v == -1 && PyErr_Occurred ()) {
103
103
PyErr_SetString (PyExc_ValueError ,
104
- "Key of options dict should be a CompressionParameter attribute." );
104
+ "Key of options dict should be either a "
105
+ "CompressionParameter attribute or an int." );
105
106
return -1 ;
106
107
}
107
108
108
- // TODO(emmatyping): check bounds when there is a value error here for better
109
- // error message?
110
109
int value_v = PyLong_AsInt (value );
111
110
if (value_v == -1 && PyErr_Occurred ()) {
112
111
PyErr_SetString (PyExc_ValueError ,
113
- "Value of option dict should be an int." );
112
+ "Value of options dict should be an int." );
114
113
return -1 ;
115
114
}
116
115
Original file line number Diff line number Diff line change @@ -112,20 +112,19 @@ _zstd_set_d_parameters(ZstdDecompressor *self, PyObject *options)
112
112
if (Py_TYPE (key ) == mod_state -> CParameter_type ) {
113
113
PyErr_SetString (PyExc_TypeError ,
114
114
"Key of decompression options dict should "
115
- "NOT be CompressionParameter." );
115
+ "NOT be a CompressionParameter attribute ." );
116
116
return -1 ;
117
117
}
118
118
119
119
/* Both key & value should be 32-bit signed int */
120
120
int key_v = PyLong_AsInt (key );
121
121
if (key_v == -1 && PyErr_Occurred ()) {
122
122
PyErr_SetString (PyExc_ValueError ,
123
- "Key of options dict should be a DecompressionParameter attribute." );
123
+ "Key of options dict should be either a "
124
+ "DecompressionParameter attribute or an int." );
124
125
return -1 ;
125
126
}
126
127
127
- // TODO(emmatyping): check bounds when there is a value error here for better
128
- // error message?
129
128
int value_v = PyLong_AsInt (value );
130
129
if (value_v == -1 && PyErr_Occurred ()) {
131
130
PyErr_SetString (PyExc_ValueError ,
You can’t perform that action at this time.
0 commit comments