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

Commit4effd06

Browse files
[3.14]gh-132983: Convert zstd__new__ methods to Argument Clinic (GH-133860) (#133915)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
1 parente20f05f commit4effd06

17 files changed

+1534
-1553
lines changed

‎Doc/data/python3.14.abi

Lines changed: 1259 additions & 1182 deletions
Large diffs are not rendered by default.

‎Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎Include/internal/pycore_global_strings.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,6 @@ struct _Py_global_strings {
395395
STRUCT_FOR_ID(deterministic)
396396
STRUCT_FOR_ID(device)
397397
STRUCT_FOR_ID(dict)
398-
STRUCT_FOR_ID(dict_content)
399398
STRUCT_FOR_ID(dictcomp)
400399
STRUCT_FOR_ID(difference_update)
401400
STRUCT_FOR_ID(digest)

‎Include/internal/pycore_runtime_init_generated.h

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎Include/internal/pycore_unicodeobject_generated.h

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎Lib/test/test_zstd.py

Lines changed: 14 additions & 10 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'Zstdcompression parameter.*?"unknown parameter \(key %d\)"' \
292-
%KEY
291+
pattern=(r'Invalid zstdcompression parameter.*?'
292+
fr'"unknown parameter \(key{KEY}\)"')
293293
withself.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'Zstddecompression parameter.*?"unknown parameter \(key %d\)"' \
424-
%KEY
423+
pattern=(r'Invalid zstddecompression parameter.*?'
424+
fr'"unknown parameter \(key{KEY}\)"')
425425
withself.assertRaisesRegex(ZstdError,pattern):
426426
ZstdDecompressor(options=options)
427427

@@ -507,7 +507,7 @@ def test_decompress_epilogue_flags(self):
507507
self.assertFalse(d.needs_input)
508508

509509
deftest_decompressor_arg(self):
510-
zd=ZstdDict(b'12345678',True)
510+
zd=ZstdDict(b'12345678',is_raw=True)
511511

512512
withself.assertRaises(TypeError):
513513
d=ZstdDecompressor(zstd_dict={})
@@ -1021,6 +1021,10 @@ def test_decompressor_skippable(self):
10211021
classZstdDictTestCase(unittest.TestCase):
10221022

10231023
deftest_is_raw(self):
1024+
# must be passed as a keyword argument
1025+
withself.assertRaises(TypeError):
1026+
ZstdDict(bytes(8),True)
1027+
10241028
# content < 8
10251029
b=b'1234567'
10261030
withself.assertRaises(ValueError):
@@ -1068,9 +1072,9 @@ def test_invalid_dict(self):
10681072

10691073
# corrupted
10701074
zd=ZstdDict(dict_content,is_raw=False)
1071-
withself.assertRaisesRegex(ZstdError,r'ZSTD_CDict.*?corrupted'):
1075+
withself.assertRaisesRegex(ZstdError,r'ZSTD_CDict.*?content\.$'):
10721076
ZstdCompressor(zstd_dict=zd.as_digested_dict)
1073-
withself.assertRaisesRegex(ZstdError,r'ZSTD_DDict.*?corrupted'):
1077+
withself.assertRaisesRegex(ZstdError,r'ZSTD_DDict.*?content\.$'):
10741078
ZstdDecompressor(zd)
10751079

10761080
# wrong type
@@ -1096,7 +1100,7 @@ def test_train_dict(self):
10961100

10971101

10981102
TRAINED_DICT=train_dict(SAMPLES,DICT_SIZE1)
1099-
ZstdDict(TRAINED_DICT.dict_content,False)
1103+
ZstdDict(TRAINED_DICT.dict_content,is_raw=False)
11001104

11011105
self.assertNotEqual(TRAINED_DICT.dict_id,0)
11021106
self.assertGreater(len(TRAINED_DICT.dict_content),0)
@@ -1250,7 +1254,7 @@ def _nbytes(dat):
12501254
deftest_as_prefix(self):
12511255
# V1
12521256
V1=THIS_FILE_BYTES
1253-
zd=ZstdDict(V1,True)
1257+
zd=ZstdDict(V1,is_raw=True)
12541258

12551259
# V2
12561260
mid=len(V1)//2
@@ -1266,7 +1270,7 @@ def test_as_prefix(self):
12661270
self.assertEqual(decompress(dat,zd.as_prefix),V2)
12671271

12681272
# use wrong prefix
1269-
zd2=ZstdDict(SAMPLES[0],True)
1273+
zd2=ZstdDict(SAMPLES[0],is_raw=True)
12701274
try:
12711275
decompressed=decompress(dat,zd2.as_prefix)
12721276
exceptZstdError:# expected

‎Modules/_zstd/_zstdmodule.c

Lines changed: 30 additions & 35 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
#ifndefPy_BUILD_CORE_BUILTIN
74
# definePy_BUILD_CORE_MODULE 1
@@ -34,17 +31,17 @@ set_zstd_error(const _zstd_state* const state,
3431
switch (type)
3532
{
3633
caseERR_DECOMPRESS:
37-
msg="Unable to decompresszstd data: %s";
34+
msg="Unable to decompressZstandard data: %s";
3835
break;
3936
caseERR_COMPRESS:
40-
msg="Unable to compresszstd data: %s";
37+
msg="Unable to compressZstandard data: %s";
4138
break;
4239

4340
caseERR_LOAD_D_DICT:
44-
msg="Unable to loadzstd dictionary or prefix for decompression: %s";
41+
msg="Unable to loadZstandard dictionary or prefix for decompression: %s";
4542
break;
4643
caseERR_LOAD_C_DICT:
47-
msg="Unable to loadzstd dictionary or prefix for compression: %s";
44+
msg="Unable to loadZstandard dictionary or prefix for compression: %s";
4845
break;
4946

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

6057
caseERR_TRAIN_DICT:
61-
msg="Unable to trainzstd dictionary: %s";
58+
msg="Unable to trainthe Zstandard dictionary: %s";
6259
break;
6360
caseERR_FINALIZE_DICT:
64-
msg="Unable to finalizezstd dictionary: %s";
61+
msg="Unable to finalizethe Zstandard dictionary: %s";
6562
break;
6663

6764
default:
@@ -152,7 +149,7 @@ set_parameter_error(const _zstd_state* const state, int is_compress,
152149
}
153150
if (ZSTD_isError(bounds.error)) {
154151
PyErr_Format(state->ZstdError,
155-
"Zstd%s parameter \"%s\" is invalid.",
152+
"Invalid zstd%s parameter \"%s\".",
156153
type,name);
157154
return;
158155
}
@@ -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+
Train a Zstandard dictionary on sample data.
191188
[clinic start generated code]*/
192189

193190
staticPyObject*
194191
_zstd_train_dict_impl(PyObject*module,PyBytesObject*samples_bytes,
195192
PyObject*samples_sizes,Py_ssize_tdict_size)
196-
/*[clinic end generated code: output=8e87fe43935e8f77 input=70fcd8937f2528b6]*/
193+
/*[clinic end generated code: output=8e87fe43935e8f77 input=d20dedb21c72cb62]*/
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.
@@ -258,7 +255,7 @@ _zstd_train_dict_impl(PyObject *module, PyBytesObject *samples_bytes,
258255
chunk_sizes, (uint32_t)chunks_number);
259256
Py_END_ALLOW_THREADS
260257

261-
/* Checkzstd dict error */
258+
/* CheckZstandard dict error */
262259
if (ZDICT_isError(zstd_ret)) {
263260
_zstd_state*constmod_state=get_zstd_state(module);
264261
set_zstd_error(mod_state,ERR_TRAIN_DICT,zstd_ret);
@@ -292,18 +289,18 @@ _zstd.finalize_dict
292289
dict_size: Py_ssize_t
293290
The size of the dictionary.
294291
compression_level: int
295-
Optimize for a specificzstd compression level, 0 means default.
292+
Optimize for a specificZstandard compression level, 0 means default.
296293
/
297294
298-
Internal function, finalize a zstd dictionary.
295+
Finalize a Zstandard dictionary.
299296
[clinic start generated code]*/
300297

301298
staticPyObject*
302299
_zstd_finalize_dict_impl(PyObject*module,PyBytesObject*custom_dict_bytes,
303300
PyBytesObject*samples_bytes,
304301
PyObject*samples_sizes,Py_ssize_tdict_size,
305302
intcompression_level)
306-
/*[clinic end generated code: output=f91821ba5ae85bda input=130d1508adb55ba1]*/
303+
/*[clinic end generated code: output=f91821ba5ae85bda input=3c7e2480aa08fb56]*/
307304
{
308305
Py_ssize_tchunks_number;
309306
size_t*chunk_sizes=NULL;
@@ -360,7 +357,7 @@ _zstd_finalize_dict_impl(PyObject *module, PyBytesObject *custom_dict_bytes,
360357

361358
/* Parameters */
362359

363-
/* Optimize for a specificzstd compression level, 0 means default. */
360+
/* Optimize for a specificZstandard compression level, 0 means default. */
364361
params.compressionLevel=compression_level;
365362
/* Write log to stderr, 0 = none. */
366363
params.notificationLevel=0;
@@ -376,7 +373,7 @@ _zstd_finalize_dict_impl(PyObject *module, PyBytesObject *custom_dict_bytes,
376373
(uint32_t)chunks_number,params);
377374
Py_END_ALLOW_THREADS
378375

379-
/* Checkzstd dict error */
376+
/* CheckZstandard dict error */
380377
if (ZDICT_isError(zstd_ret)) {
381378
_zstd_state*constmod_state=get_zstd_state(module);
382379
set_zstd_error(mod_state,ERR_FINALIZE_DICT,zstd_ret);
@@ -407,12 +404,12 @@ _zstd.get_param_bounds
407404
is_compress: bool
408405
True for CompressionParameter, False for DecompressionParameter.
409406
410-
Internal function, get CompressionParameter/DecompressionParameter bounds.
407+
Get CompressionParameter/DecompressionParameter bounds.
411408
[clinic start generated code]*/
412409

413410
staticPyObject*
414411
_zstd_get_param_bounds_impl(PyObject*module,intparameter,intis_compress)
415-
/*[clinic end generated code: output=4acf5a876f0620ca input=84e669591e487008]*/
412+
/*[clinic end generated code: output=4acf5a876f0620ca input=45742ef0a3531b65]*/
416413
{
417414
ZSTD_boundsbound;
418415
if (is_compress) {
@@ -442,24 +439,22 @@ _zstd.get_frame_size
442439
A bytes-like object, it should start from the beginning of a frame,
443440
and contains at least one complete frame.
444441
445-
Get the size of a zstd frame, including frame header and 4-byte checksum if it has one.
446-
447-
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.
448443
[clinic start generated code]*/
449444

450445
staticPyObject*
451446
_zstd_get_frame_size_impl(PyObject*module,Py_buffer*frame_buffer)
452-
/*[clinic end generated code: output=a7384c2f8780f442 input=7d3ad24311893bf3]*/
447+
/*[clinic end generated code: output=a7384c2f8780f442 input=3b9f73f8c8129d38]*/
453448
{
454449
size_tframe_size;
455450

456451
frame_size=ZSTD_findFrameCompressedSize(frame_buffer->buf,frame_buffer->len);
457452
if (ZSTD_isError(frame_size)) {
458453
_zstd_state*constmod_state=get_zstd_state(module);
459454
PyErr_Format(mod_state->ZstdError,
460-
"Error when finding the compressed size of azstd frame. "
461-
"Make sure the frame_buffer argument starts from the "
462-
"beginning of a frame, and its length not less than this "
455+
"Error when finding the compressed size of aZstandard frame. "
456+
"Ensure the frame_buffer argument starts from the "
457+
"beginning of a frame, and its lengthisnot less than this "
463458
"complete frame. Zstd error message: %s.",
464459
ZSTD_getErrorName(frame_size));
465460
returnNULL;
@@ -472,14 +467,14 @@ _zstd_get_frame_size_impl(PyObject *module, Py_buffer *frame_buffer)
472467
_zstd.get_frame_info
473468
474469
frame_buffer: Py_buffer
475-
A bytes-like object, containing the header of azstd frame.
470+
A bytes-like object, containing the header of aZstandard frame.
476471
477-
Internal function, get zstd frame infomation from a frame header.
472+
Get Zstandard frame infomation from a frame header.
478473
[clinic start generated code]*/
479474

480475
staticPyObject*
481476
_zstd_get_frame_info_impl(PyObject*module,Py_buffer*frame_buffer)
482-
/*[clinic end generated code: output=56e033cf48001929 input=1816f14656b6aa22]*/
477+
/*[clinic end generated code: output=56e033cf48001929 input=94b240583ae22ca5]*/
483478
{
484479
uint64_tdecompressed_size;
485480
uint32_tdict_id;
@@ -494,9 +489,9 @@ _zstd_get_frame_info_impl(PyObject *module, Py_buffer *frame_buffer)
494489
_zstd_state*constmod_state=get_zstd_state(module);
495490
PyErr_SetString(mod_state->ZstdError,
496491
"Error when getting information from the header of "
497-
"azstd frame.Make sure the frame_buffer argument "
492+
"aZstandard frame.Ensure the frame_buffer argument "
498493
"starts from the beginning of a frame, and its length "
499-
"not less than the frame header (6~18 bytes).");
494+
"isnot less than the frame header (6~18 bytes).");
500495
returnNULL;
501496
}
502497

@@ -518,13 +513,13 @@ _zstd.set_parameter_types
518513
d_parameter_type: object(subclass_of='&PyType_Type')
519514
DecompressionParameter IntEnum type object
520515
521-
Internal function, set CompressionParameter/DecompressionParameter types for validity check.
516+
Set CompressionParameter andDecompressionParameter types for validity check.
522517
[clinic start generated code]*/
523518

524519
staticPyObject*
525520
_zstd_set_parameter_types_impl(PyObject*module,PyObject*c_parameter_type,
526521
PyObject*d_parameter_type)
527-
/*[clinic end generated code: output=f3313b1294f19502 input=30402523871b8280]*/
522+
/*[clinic end generated code: output=f3313b1294f19502 input=75d7a953580fae5f]*/
528523
{
529524
_zstd_state*constmod_state=get_zstd_state(module);
530525

‎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
#ifndefZSTD_BUFFER_H
74
#defineZSTD_BUFFER_H

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp