Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Make zstd types immutable
  • Loading branch information
AA-Turner committed May 9, 2025
commit 9be36ca8bb06c684052cb2021e58df316fe335d7
3 changes: 3 additions & 0 deletions Modules/_zstd/_zstdmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,9 @@ do { \
ADD_INT_CONST_TO_TYPE(mod_state->ZstdCompressor_type,
"FLUSH_FRAME", ZSTD_e_end);

/* Make ZstdCompressor immutable */
PyType_Freeze(mod_state->ZstdCompressor_type);
Comment thread
AA-Turner marked this conversation as resolved.

#undef ADD_TYPE
#undef ADD_INT_MACRO
#undef ADD_ZSTD_COMPRESSOR_INT_CONST
Expand Down
3 changes: 2 additions & 1 deletion Modules/_zstd/decompressor.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,7 @@ static PyType_Slot ZstdDecompressor_slots[] = {
PyType_Spec zstd_decompressor_type_spec = {
.name = "_zstd.ZstdDecompressor",
.basicsize = sizeof(ZstdDecompressor),
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE
| Py_TPFLAGS_HAVE_GC,
.slots = ZstdDecompressor_slots,
};
3 changes: 2 additions & 1 deletion Modules/_zstd/zstddict.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ static PyType_Slot zstddict_slots[] = {
PyType_Spec zstd_dict_type_spec = {
.name = "_zstd.ZstdDict",
.basicsize = sizeof(ZstdDict),
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE
| Py_TPFLAGS_HAVE_GC,
.slots = zstddict_slots,
};