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

Commit1a87b6e

Browse files
authored
gh-132983: Make zstd types immutable (#133784)
1 parentdc191d2 commit1a87b6e

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

‎Modules/_zstd/_zstdmodule.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,9 @@ do { \
679679
ADD_INT_CONST_TO_TYPE(mod_state->ZstdCompressor_type,
680680
"FLUSH_FRAME",ZSTD_e_end);
681681

682+
/* Make ZstdCompressor immutable (set Py_TPFLAGS_IMMUTABLETYPE) */
683+
PyType_Freeze(mod_state->ZstdCompressor_type);
684+
682685
#undef ADD_TYPE
683686
#undef ADD_INT_MACRO
684687
#undef ADD_ZSTD_COMPRESSOR_INT_CONST

‎Modules/_zstd/compressor.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,9 @@ static PyType_Slot zstdcompressor_slots[] = {
729729
PyType_Speczstd_compressor_type_spec= {
730730
.name="compression.zstd.ZstdCompressor",
731731
.basicsize=sizeof(ZstdCompressor),
732+
// Py_TPFLAGS_IMMUTABLETYPE is not used here as several
733+
// associated constants need to be added to the type.
734+
// PyType_Freeze is called later to set the flag.
732735
.flags=Py_TPFLAGS_DEFAULT |Py_TPFLAGS_HAVE_GC,
733736
.slots=zstdcompressor_slots,
734737
};

‎Modules/_zstd/decompressor.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,7 @@ static PyType_Slot ZstdDecompressor_slots[] = {
902902
PyType_Speczstd_decompressor_type_spec= {
903903
.name="compression.zstd.ZstdDecompressor",
904904
.basicsize=sizeof(ZstdDecompressor),
905-
.flags=Py_TPFLAGS_DEFAULT |Py_TPFLAGS_HAVE_GC,
905+
.flags=Py_TPFLAGS_DEFAULT |Py_TPFLAGS_IMMUTABLETYPE
906+
|Py_TPFLAGS_HAVE_GC,
906907
.slots=ZstdDecompressor_slots,
907908
};

‎Modules/_zstd/zstddict.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ static PyType_Slot zstddict_slots[] = {
278278
PyType_Speczstd_dict_type_spec= {
279279
.name="compression.zstd.ZstdDict",
280280
.basicsize=sizeof(ZstdDict),
281-
.flags=Py_TPFLAGS_DEFAULT |Py_TPFLAGS_HAVE_GC,
281+
.flags=Py_TPFLAGS_DEFAULT |Py_TPFLAGS_IMMUTABLETYPE
282+
|Py_TPFLAGS_HAVE_GC,
282283
.slots=zstddict_slots,
283284
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp