From 46855aac4da7f67b8ecc4c0c6a3fcabaff473c1b Mon Sep 17 00:00:00 2001 From: Rogdham Date: Sat, 2 Aug 2025 11:14:46 +0200 Subject: [PATCH 1/5] ZstdDict: fix docstrings --- Lib/compression/zstd/__init__.py | 2 +- Modules/_zstd/clinic/zstddict.c.h | 2 +- Modules/_zstd/zstddict.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/compression/zstd/__init__.py b/Lib/compression/zstd/__init__.py index 84b25914b0aa93..ec98a835dd9263 100644 --- a/Lib/compression/zstd/__init__.py +++ b/Lib/compression/zstd/__init__.py @@ -11,6 +11,7 @@ 'get_frame_info', 'Strategy', 'train_dict', + 'zstd_version_info', # compression.zstd._zstdfile 'open', @@ -19,7 +20,6 @@ # _zstd 'get_frame_size', 'zstd_version', - 'zstd_version_info', 'ZstdCompressor', 'ZstdDecompressor', 'ZstdDict', diff --git a/Modules/_zstd/clinic/zstddict.c.h b/Modules/_zstd/clinic/zstddict.c.h index 79db85405d6e6b..4bc7e526c7417a 100644 --- a/Modules/_zstd/clinic/zstddict.c.h +++ b/Modules/_zstd/clinic/zstddict.c.h @@ -198,7 +198,7 @@ PyDoc_STRVAR(_zstd_ZstdDict_as_prefix__doc__, "1. Prefix is compatible with long distance matching, while dictionary is not.\n" "2. It only works for the first frame, then the compressor/decompressor will\n" " return to no prefix state.\n" -"3. When decompressing, must use the same prefix as when compressing.\""); +"3. When decompressing, must use the same prefix as when compressing."); #if defined(_zstd_ZstdDict_as_prefix_DOCSTR) # undef _zstd_ZstdDict_as_prefix_DOCSTR #endif diff --git a/Modules/_zstd/zstddict.c b/Modules/_zstd/zstddict.c index 35d6ca8e55a265..18a326d6c109f2 100644 --- a/Modules/_zstd/zstddict.c +++ b/Modules/_zstd/zstddict.c @@ -120,9 +120,9 @@ ZstdDict_dealloc(PyObject *ob) PyDoc_STRVAR(ZstdDict_dictid_doc, "the Zstandard dictionary, an int between 0 and 2**32.\n\n" -"A non-zero value represents an ordinary Zstandard dictionary, " +"A non-zero value represents an ordinary Zstandard dictionary,\n" "conforming to the standardised format.\n\n" -"The special value '0' means a 'raw content' dictionary," +"The special value '0' means a 'raw content' dictionary,\n" "without any restrictions on format or content."); static PyObject * From 1739ffaf5ecf04fa1e5e739444136e24ec6f222b Mon Sep 17 00:00:00 2001 From: Rogdham Date: Sat, 2 Aug 2025 11:26:20 +0200 Subject: [PATCH 2/5] Run make regen-all --- Modules/_zstd/clinic/zstddict.c.h | 2 +- Programs/test_frozenmain.h | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Modules/_zstd/clinic/zstddict.c.h b/Modules/_zstd/clinic/zstddict.c.h index 4bc7e526c7417a..79db85405d6e6b 100644 --- a/Modules/_zstd/clinic/zstddict.c.h +++ b/Modules/_zstd/clinic/zstddict.c.h @@ -198,7 +198,7 @@ PyDoc_STRVAR(_zstd_ZstdDict_as_prefix__doc__, "1. Prefix is compatible with long distance matching, while dictionary is not.\n" "2. It only works for the first frame, then the compressor/decompressor will\n" " return to no prefix state.\n" -"3. When decompressing, must use the same prefix as when compressing."); +"3. When decompressing, must use the same prefix as when compressing.\""); #if defined(_zstd_ZstdDict_as_prefix_DOCSTR) # undef _zstd_ZstdDict_as_prefix_DOCSTR #endif diff --git a/Programs/test_frozenmain.h b/Programs/test_frozenmain.h index dbeedb7ffe0ce6..b9bf4134b59718 100644 --- a/Programs/test_frozenmain.h +++ b/Programs/test_frozenmain.h @@ -13,10 +13,10 @@ unsigned char M_test_frozenmain[] = { 82,5,93,6,12,0,82,6,93,5,93,6,44,26,0,0, 0,0,0,0,0,0,0,0,12,0,50,4,52,1,0,0, 0,0,0,0,31,0,75,26,0,0,9,0,30,0,82,1, - 35,0,41,8,233,0,0,0,0,78,122,18,70,114,111,122, - 101,110,32,72,101,108,108,111,32,87,111,114,108,100,122,8, + 35,0,41,8,233,0,0,0,0,78,218,18,70,114,111,122, + 101,110,32,72,101,108,108,111,32,87,111,114,108,100,218,8, 115,121,115,46,97,114,103,118,218,6,99,111,110,102,105,103, - 122,7,99,111,110,102,105,103,32,122,2,58,32,41,5,218, + 218,7,99,111,110,102,105,103,32,218,2,58,32,41,5,218, 12,112,114,111,103,114,97,109,95,110,97,109,101,218,10,101, 120,101,99,117,116,97,98,108,101,218,15,117,115,101,95,101, 110,118,105,114,111,110,109,101,110,116,218,17,99,111,110,102, @@ -25,15 +25,15 @@ unsigned char M_test_frozenmain[] = { 3,115,121,115,218,17,95,116,101,115,116,105,110,116,101,114, 110,97,108,99,97,112,105,218,5,112,114,105,110,116,218,4, 97,114,103,118,218,11,103,101,116,95,99,111,110,102,105,103, - 115,114,3,0,0,0,218,3,107,101,121,169,0,243,0,0, + 115,114,5,0,0,0,218,3,107,101,121,169,0,243,0,0, 0,0,218,18,116,101,115,116,95,102,114,111,122,101,110,109, 97,105,110,46,112,121,218,8,60,109,111,100,117,108,101,62, - 114,18,0,0,0,1,0,0,0,115,94,0,0,0,240,3, + 114,22,0,0,0,1,0,0,0,115,94,0,0,0,240,3, 1,1,1,243,8,0,1,11,219,0,24,225,0,5,208,6, 26,212,0,27,217,0,5,128,106,144,35,151,40,145,40,212, 0,27,216,9,26,215,9,38,210,9,38,211,9,40,168,24, 213,9,50,128,6,243,2,6,12,2,128,67,241,14,0,5, 10,136,71,144,67,144,53,152,2,152,54,160,35,157,59,152, - 45,208,10,40,214,4,41,243,15,6,12,2,114,16,0,0, + 45,208,10,40,214,4,41,243,15,6,12,2,114,20,0,0, 0, }; From 8447b658762a4144e5911b5dfc36118ab65d048c Mon Sep 17 00:00:00 2001 From: Rogdham Date: Sat, 2 Aug 2025 11:38:51 +0200 Subject: [PATCH 3/5] Revert "Run make regen-all" and run clinic instead --- Modules/_zstd/clinic/zstddict.c.h | 4 ++-- Modules/_zstd/zstddict.c | 4 ++-- Programs/test_frozenmain.h | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Modules/_zstd/clinic/zstddict.c.h b/Modules/_zstd/clinic/zstddict.c.h index 79db85405d6e6b..166d925a542352 100644 --- a/Modules/_zstd/clinic/zstddict.c.h +++ b/Modules/_zstd/clinic/zstddict.c.h @@ -198,7 +198,7 @@ PyDoc_STRVAR(_zstd_ZstdDict_as_prefix__doc__, "1. Prefix is compatible with long distance matching, while dictionary is not.\n" "2. It only works for the first frame, then the compressor/decompressor will\n" " return to no prefix state.\n" -"3. When decompressing, must use the same prefix as when compressing.\""); +"3. When decompressing, must use the same prefix as when compressing."); #if defined(_zstd_ZstdDict_as_prefix_DOCSTR) # undef _zstd_ZstdDict_as_prefix_DOCSTR #endif @@ -222,4 +222,4 @@ _zstd_ZstdDict_as_prefix_get(PyObject *self, void *Py_UNUSED(context)) { return _zstd_ZstdDict_as_prefix_get_impl((ZstdDict *)self); } -/*[clinic end generated code: output=4696cbc722e5fdfc input=a9049054013a1b77]*/ +/*[clinic end generated code: output=f41d9e2e2cc2928f input=a9049054013a1b77]*/ diff --git a/Modules/_zstd/zstddict.c b/Modules/_zstd/zstddict.c index 18a326d6c109f2..6a8458dcbb1745 100644 --- a/Modules/_zstd/zstddict.c +++ b/Modules/_zstd/zstddict.c @@ -210,12 +210,12 @@ compress(dat, zstd_dict=zd.as_prefix) 1. Prefix is compatible with long distance matching, while dictionary is not. 2. It only works for the first frame, then the compressor/decompressor will return to no prefix state. -3. When decompressing, must use the same prefix as when compressing." +3. When decompressing, must use the same prefix as when compressing. [clinic start generated code]*/ static PyObject * _zstd_ZstdDict_as_prefix_get_impl(ZstdDict *self) -/*[clinic end generated code: output=6f7130c356595a16 input=d59757b0b5a9551a]*/ +/*[clinic end generated code: output=6f7130c356595a16 input=45b3b6110f36d127]*/ { return Py_BuildValue("Oi", self, DICT_TYPE_PREFIX); } diff --git a/Programs/test_frozenmain.h b/Programs/test_frozenmain.h index b9bf4134b59718..dbeedb7ffe0ce6 100644 --- a/Programs/test_frozenmain.h +++ b/Programs/test_frozenmain.h @@ -13,10 +13,10 @@ unsigned char M_test_frozenmain[] = { 82,5,93,6,12,0,82,6,93,5,93,6,44,26,0,0, 0,0,0,0,0,0,0,0,12,0,50,4,52,1,0,0, 0,0,0,0,31,0,75,26,0,0,9,0,30,0,82,1, - 35,0,41,8,233,0,0,0,0,78,218,18,70,114,111,122, - 101,110,32,72,101,108,108,111,32,87,111,114,108,100,218,8, + 35,0,41,8,233,0,0,0,0,78,122,18,70,114,111,122, + 101,110,32,72,101,108,108,111,32,87,111,114,108,100,122,8, 115,121,115,46,97,114,103,118,218,6,99,111,110,102,105,103, - 218,7,99,111,110,102,105,103,32,218,2,58,32,41,5,218, + 122,7,99,111,110,102,105,103,32,122,2,58,32,41,5,218, 12,112,114,111,103,114,97,109,95,110,97,109,101,218,10,101, 120,101,99,117,116,97,98,108,101,218,15,117,115,101,95,101, 110,118,105,114,111,110,109,101,110,116,218,17,99,111,110,102, @@ -25,15 +25,15 @@ unsigned char M_test_frozenmain[] = { 3,115,121,115,218,17,95,116,101,115,116,105,110,116,101,114, 110,97,108,99,97,112,105,218,5,112,114,105,110,116,218,4, 97,114,103,118,218,11,103,101,116,95,99,111,110,102,105,103, - 115,114,5,0,0,0,218,3,107,101,121,169,0,243,0,0, + 115,114,3,0,0,0,218,3,107,101,121,169,0,243,0,0, 0,0,218,18,116,101,115,116,95,102,114,111,122,101,110,109, 97,105,110,46,112,121,218,8,60,109,111,100,117,108,101,62, - 114,22,0,0,0,1,0,0,0,115,94,0,0,0,240,3, + 114,18,0,0,0,1,0,0,0,115,94,0,0,0,240,3, 1,1,1,243,8,0,1,11,219,0,24,225,0,5,208,6, 26,212,0,27,217,0,5,128,106,144,35,151,40,145,40,212, 0,27,216,9,26,215,9,38,210,9,38,211,9,40,168,24, 213,9,50,128,6,243,2,6,12,2,128,67,241,14,0,5, 10,136,71,144,67,144,53,152,2,152,54,160,35,157,59,152, - 45,208,10,40,214,4,41,243,15,6,12,2,114,20,0,0, + 45,208,10,40,214,4,41,243,15,6,12,2,114,16,0,0, 0, }; From ebca5a9783b1ef3fb691e8ff462b837969b42a3c Mon Sep 17 00:00:00 2001 From: Rogdham Date: Sat, 2 Aug 2025 12:06:37 +0200 Subject: [PATCH 4/5] Revert changes in __init_.py --- Lib/compression/zstd/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/compression/zstd/__init__.py b/Lib/compression/zstd/__init__.py index ec98a835dd9263..84b25914b0aa93 100644 --- a/Lib/compression/zstd/__init__.py +++ b/Lib/compression/zstd/__init__.py @@ -11,7 +11,6 @@ 'get_frame_info', 'Strategy', 'train_dict', - 'zstd_version_info', # compression.zstd._zstdfile 'open', @@ -20,6 +19,7 @@ # _zstd 'get_frame_size', 'zstd_version', + 'zstd_version_info', 'ZstdCompressor', 'ZstdDecompressor', 'ZstdDict', From 5d6a4adfbb5c476d0e86e279a6dddbc1131b8bd6 Mon Sep 17 00:00:00 2001 From: Rogdham Date: Sun, 3 Aug 2025 16:38:09 +0200 Subject: [PATCH 5/5] Apply Adam Turner suggestions --- Modules/_zstd/zstddict.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/_zstd/zstddict.c b/Modules/_zstd/zstddict.c index 6a8458dcbb1745..76e966f5b1b52a 100644 --- a/Modules/_zstd/zstddict.c +++ b/Modules/_zstd/zstddict.c @@ -119,10 +119,10 @@ ZstdDict_dealloc(PyObject *ob) } PyDoc_STRVAR(ZstdDict_dictid_doc, -"the Zstandard dictionary, an int between 0 and 2**32.\n\n" +"The Zstandard dictionary, an int between 0 and 2**32.\n\n" "A non-zero value represents an ordinary Zstandard dictionary,\n" "conforming to the standardised format.\n\n" -"The special value '0' means a 'raw content' dictionary,\n" +"A value of zero indicates a 'raw content' dictionary,\n" "without any restrictions on format or content."); static PyObject *