mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
[3.14] gh-132983: Make zstd types immutable (GH-133784) (#133857)
gh-132983: Make zstd types immutable (GH-133784)
(cherry picked from commit 1a87b6e9ae
)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
This commit is contained in:
parent
da1e5c434b
commit
1e8a534533
4 changed files with 10 additions and 2 deletions
|
@ -679,6 +679,9 @@ do { \
|
||||||
ADD_INT_CONST_TO_TYPE(mod_state->ZstdCompressor_type,
|
ADD_INT_CONST_TO_TYPE(mod_state->ZstdCompressor_type,
|
||||||
"FLUSH_FRAME", ZSTD_e_end);
|
"FLUSH_FRAME", ZSTD_e_end);
|
||||||
|
|
||||||
|
/* Make ZstdCompressor immutable (set Py_TPFLAGS_IMMUTABLETYPE) */
|
||||||
|
PyType_Freeze(mod_state->ZstdCompressor_type);
|
||||||
|
|
||||||
#undef ADD_TYPE
|
#undef ADD_TYPE
|
||||||
#undef ADD_INT_MACRO
|
#undef ADD_INT_MACRO
|
||||||
#undef ADD_ZSTD_COMPRESSOR_INT_CONST
|
#undef ADD_ZSTD_COMPRESSOR_INT_CONST
|
||||||
|
|
|
@ -729,6 +729,9 @@ static PyType_Slot zstdcompressor_slots[] = {
|
||||||
PyType_Spec zstd_compressor_type_spec = {
|
PyType_Spec zstd_compressor_type_spec = {
|
||||||
.name = "compression.zstd.ZstdCompressor",
|
.name = "compression.zstd.ZstdCompressor",
|
||||||
.basicsize = sizeof(ZstdCompressor),
|
.basicsize = sizeof(ZstdCompressor),
|
||||||
|
// Py_TPFLAGS_IMMUTABLETYPE is not used here as several
|
||||||
|
// associated constants need to be added to the type.
|
||||||
|
// PyType_Freeze is called later to set the flag.
|
||||||
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
|
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
|
||||||
.slots = zstdcompressor_slots,
|
.slots = zstdcompressor_slots,
|
||||||
};
|
};
|
||||||
|
|
|
@ -902,6 +902,7 @@ static PyType_Slot ZstdDecompressor_slots[] = {
|
||||||
PyType_Spec zstd_decompressor_type_spec = {
|
PyType_Spec zstd_decompressor_type_spec = {
|
||||||
.name = "compression.zstd.ZstdDecompressor",
|
.name = "compression.zstd.ZstdDecompressor",
|
||||||
.basicsize = sizeof(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,
|
.slots = ZstdDecompressor_slots,
|
||||||
};
|
};
|
||||||
|
|
|
@ -278,6 +278,7 @@ static PyType_Slot zstddict_slots[] = {
|
||||||
PyType_Spec zstd_dict_type_spec = {
|
PyType_Spec zstd_dict_type_spec = {
|
||||||
.name = "compression.zstd.ZstdDict",
|
.name = "compression.zstd.ZstdDict",
|
||||||
.basicsize = sizeof(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,
|
.slots = zstddict_slots,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue