Skip to content

Commit 9be36ca

Browse files
committed
Make zstd types immutable
1 parent bbe9c31 commit 9be36ca

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

Modules/_zstd/_zstdmodule.c

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

685+
/* Make ZstdCompressor immutable */
686+
PyType_Freeze(mod_state->ZstdCompressor_type);
687+
685688
#undef ADD_TYPE
686689
#undef ADD_INT_MACRO
687690
#undef ADD_ZSTD_COMPRESSOR_INT_CONST

Modules/_zstd/decompressor.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,7 @@ static PyType_Slot ZstdDecompressor_slots[] = {
886886
PyType_Spec zstd_decompressor_type_spec = {
887887
.name = "_zstd.ZstdDecompressor",
888888
.basicsize = sizeof(ZstdDecompressor),
889-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
889+
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE
890+
| Py_TPFLAGS_HAVE_GC,
890891
.slots = ZstdDecompressor_slots,
891892
};

Modules/_zstd/zstddict.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ static PyType_Slot zstddict_slots[] = {
281281
PyType_Spec zstd_dict_type_spec = {
282282
.name = "_zstd.ZstdDict",
283283
.basicsize = sizeof(ZstdDict),
284-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
284+
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE
285+
| Py_TPFLAGS_HAVE_GC,
285286
.slots = zstddict_slots,
286287
};

0 commit comments

Comments
 (0)