From 00710e6346fd2394aa020b2dfae170093effac98 Mon Sep 17 00:00:00 2001 From: Erlend Egeberg Aasland Date: Thu, 17 Jun 2021 12:06:09 +0200 Subject: bpo-43908: Make heap types converted during 3.10 alpha immutable (GH-26351) * Make functools types immutable * Multibyte codec types are now immutable * pyexpat.xmlparser is now immutable * array.arrayiterator is now immutable * _thread types are now immutable * _csv types are now immutable * _queue.SimpleQueue is now immutable * mmap.mmap is now immutable * unicodedata.UCD is now immutable * sqlite3 types are now immutable * _lsprof.Profiler is now immutable * _overlapped.Overlapped is now immutable * _operator types are now immutable * winapi__overlapped.Overlapped is now immutable * _lzma types are now immutable * _bz2 types are now immutable * _dbm.dbm and _gdbm.gdbm are now immutable --- Modules/_bz2module.c | 4 ++-- Modules/_csv.c | 9 ++++++--- Modules/_dbmmodule.c | 2 +- Modules/_functoolsmodule.c | 10 ++++++---- Modules/_gdbmmodule.c | 2 +- Modules/_lsprof.c | 3 ++- Modules/_lzmamodule.c | 4 ++-- Modules/_operator.c | 9 ++++++--- Modules/_queuemodule.c | 3 ++- Modules/_sqlite/connection.c | 3 ++- Modules/_sqlite/cursor.c | 3 ++- Modules/_sqlite/prepare_protocol.c | 3 ++- Modules/_sqlite/row.c | 3 ++- Modules/_sqlite/statement.c | 3 ++- Modules/_threadmodule.c | 11 +++++++---- Modules/_winapi.c | 2 +- Modules/arraymodule.c | 2 +- Modules/cjkcodecs/multibytecodec.c | 14 +++++++++----- Modules/mmapmodule.c | 3 ++- Modules/overlapped.c | 2 +- Modules/pyexpat.c | 2 +- Modules/unicodedata.c | 2 +- 22 files changed, 61 insertions(+), 38 deletions(-) diff --git a/Modules/_bz2module.c b/Modules/_bz2module.c index d75bb32..798e9ef 100644 --- a/Modules/_bz2module.c +++ b/Modules/_bz2module.c @@ -422,7 +422,7 @@ static PyType_Spec bz2_compressor_type_spec = { // bz2_compressor_type_spec does not have Py_TPFLAGS_BASETYPE flag // which prevents to create a subclass. // So calling PyType_GetModuleState() in this file is always safe. - .flags = Py_TPFLAGS_DEFAULT, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE), .slots = bz2_compressor_type_slots, }; @@ -766,7 +766,7 @@ static PyType_Spec bz2_decompressor_type_spec = { // bz2_decompressor_type_spec does not have Py_TPFLAGS_BASETYPE flag // which prevents to create a subclass. // So calling PyType_GetModuleState() in this file is always safe. - .flags = Py_TPFLAGS_DEFAULT, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE), .slots = bz2_decompressor_type_slots, }; diff --git a/Modules/_csv.c b/Modules/_csv.c index a213734..78855b8 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -537,7 +537,8 @@ static PyType_Slot Dialect_Type_slots[] = { PyType_Spec Dialect_Type_spec = { .name = "_csv.Dialect", .basicsize = sizeof(DialectObj), - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | + Py_TPFLAGS_IMMUTABLETYPE), .slots = Dialect_Type_slots, }; @@ -958,7 +959,8 @@ static PyType_Slot Reader_Type_slots[] = { PyType_Spec Reader_Type_spec = { .name = "_csv.reader", .basicsize = sizeof(ReaderObj), - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | + Py_TPFLAGS_IMMUTABLETYPE), .slots = Reader_Type_slots }; @@ -1382,7 +1384,8 @@ static PyType_Slot Writer_Type_slots[] = { PyType_Spec Writer_Type_spec = { .name = "_csv.writer", .basicsize = sizeof(WriterObj), - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | + Py_TPFLAGS_IMMUTABLETYPE), .slots = Writer_Type_slots, }; diff --git a/Modules/_dbmmodule.c b/Modules/_dbmmodule.c index 2b4d071..3fe97ef 100644 --- a/Modules/_dbmmodule.c +++ b/Modules/_dbmmodule.c @@ -423,7 +423,7 @@ static PyType_Spec dbmtype_spec = { // which prevents to create a subclass. // So calling PyType_GetModuleState() in this file is always safe. .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION | - Py_TPFLAGS_HAVE_GC), + Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE), .slots = dbmtype_spec_slots, }; diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c index 218a8d1..fa14521 100644 --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -491,7 +491,8 @@ static PyType_Spec partial_type_spec = { .name = "functools.partial", .basicsize = sizeof(partialobject), .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_VECTORCALL, + Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_VECTORCALL | + Py_TPFLAGS_IMMUTABLETYPE, .slots = partial_type_slots }; @@ -559,7 +560,7 @@ static PyType_Spec keyobject_type_spec = { .name = "functools.KeyWrapper", .basicsize = sizeof(keyobject), .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION | - Py_TPFLAGS_HAVE_GC), + Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE), .slots = keyobject_type_slots }; @@ -781,7 +782,8 @@ static PyType_Slot lru_list_elem_type_slots[] = { static PyType_Spec lru_list_elem_type_spec = { .name = "functools._lru_list_elem", .basicsize = sizeof(lru_list_elem), - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION, + .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION | + Py_TPFLAGS_IMMUTABLETYPE, .slots = lru_list_elem_type_slots }; @@ -1417,7 +1419,7 @@ static PyType_Spec lru_cache_type_spec = { .name = "functools._lru_cache_wrapper", .basicsize = sizeof(lru_cache_object), .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_METHOD_DESCRIPTOR, + Py_TPFLAGS_METHOD_DESCRIPTOR | Py_TPFLAGS_IMMUTABLETYPE, .slots = lru_cache_type_slots }; diff --git a/Modules/_gdbmmodule.c b/Modules/_gdbmmodule.c index 98bfa6a..8a8c6e7 100644 --- a/Modules/_gdbmmodule.c +++ b/Modules/_gdbmmodule.c @@ -581,7 +581,7 @@ static PyType_Spec gdbmtype_spec = { // which prevents to create a subclass. // So calling PyType_GetModuleState() in this file is always safe. .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION | - Py_TPFLAGS_HAVE_GC), + Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE), .slots = gdbmtype_spec_slots, }; diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c index a0e6afa..703067c 100644 --- a/Modules/_lsprof.c +++ b/Modules/_lsprof.c @@ -812,7 +812,8 @@ static PyType_Slot _lsprof_profiler_type_spec_slots[] = { static PyType_Spec _lsprof_profiler_type_spec = { .name = "_lsprof.Profiler", .basicsize = sizeof(ProfilerObject), - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE), .slots = _lsprof_profiler_type_spec_slots, }; diff --git a/Modules/_lzmamodule.c b/Modules/_lzmamodule.c index 2f80bf0..915c0c9 100644 --- a/Modules/_lzmamodule.c +++ b/Modules/_lzmamodule.c @@ -915,7 +915,7 @@ static PyType_Spec lzma_compressor_type_spec = { // lzma_compressor_type_spec does not have Py_TPFLAGS_BASETYPE flag // which prevents to create a subclass. // So calling PyType_GetModuleState() in this file is always safe. - .flags = Py_TPFLAGS_DEFAULT, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE), .slots = lzma_compressor_type_slots, }; @@ -1359,7 +1359,7 @@ static PyType_Spec lzma_decompressor_type_spec = { // lzma_decompressor_type_spec does not have Py_TPFLAGS_BASETYPE flag // which prevents to create a subclass. // So calling PyType_GetModuleState() in this file is always safe. - .flags = Py_TPFLAGS_DEFAULT, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE), .slots = lzma_decompressor_type_slots, }; diff --git a/Modules/_operator.c b/Modules/_operator.c index 5bd5a3b..d5e092e 100644 --- a/Modules/_operator.c +++ b/Modules/_operator.c @@ -1133,7 +1133,8 @@ static PyType_Spec itemgetter_type_spec = { .name = "operator.itemgetter", .basicsize = sizeof(itemgetterobject), .itemsize = 0, - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | + Py_TPFLAGS_IMMUTABLETYPE), .slots = itemgetter_type_slots, }; @@ -1464,7 +1465,8 @@ static PyType_Spec attrgetter_type_spec = { .name = "operator.attrgetter", .basicsize = sizeof(attrgetterobject), .itemsize = 0, - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | + Py_TPFLAGS_IMMUTABLETYPE), .slots = attrgetter_type_slots, }; @@ -1719,7 +1721,8 @@ static PyType_Spec methodcaller_type_spec = { .name = "operator.methodcaller", .basicsize = sizeof(methodcallerobject), .itemsize = 0, - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | + Py_TPFLAGS_IMMUTABLETYPE), .slots = methodcaller_type_slots, }; diff --git a/Modules/_queuemodule.c b/Modules/_queuemodule.c index 5e0f38f..a124255 100644 --- a/Modules/_queuemodule.c +++ b/Modules/_queuemodule.c @@ -380,7 +380,8 @@ static PyType_Slot simplequeue_slots[] = { static PyType_Spec simplequeue_spec = { .name = "_queue.SimpleQueue", .basicsize = sizeof(simplequeueobject), - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | + Py_TPFLAGS_IMMUTABLETYPE), .slots = simplequeue_slots, }; diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 915515c..e1eef58 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -1914,7 +1914,8 @@ static PyType_Slot connection_slots[] = { static PyType_Spec connection_spec = { .name = MODULE_NAME ".Connection", .basicsize = sizeof(pysqlite_Connection), - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE), .slots = connection_slots, }; diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index 8c8a347..8e7d65f 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -1078,7 +1078,8 @@ static PyType_Slot cursor_slots[] = { static PyType_Spec cursor_spec = { .name = MODULE_NAME ".Cursor", .basicsize = sizeof(pysqlite_Cursor), - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE), .slots = cursor_slots, }; diff --git a/Modules/_sqlite/prepare_protocol.c b/Modules/_sqlite/prepare_protocol.c index 1f9d7b7..cefb46e 100644 --- a/Modules/_sqlite/prepare_protocol.c +++ b/Modules/_sqlite/prepare_protocol.c @@ -56,7 +56,8 @@ static PyType_Slot type_slots[] = { static PyType_Spec type_spec = { .name = MODULE_NAME ".PrepareProtocol", .basicsize = sizeof(pysqlite_PrepareProtocol), - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | + Py_TPFLAGS_IMMUTABLETYPE), .slots = type_slots, }; diff --git a/Modules/_sqlite/row.c b/Modules/_sqlite/row.c index bf43dad..d2f9bdd 100644 --- a/Modules/_sqlite/row.c +++ b/Modules/_sqlite/row.c @@ -258,7 +258,8 @@ static PyType_Slot row_slots[] = { static PyType_Spec row_spec = { .name = MODULE_NAME ".Row", .basicsize = sizeof(pysqlite_Row), - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE), .slots = row_slots, }; diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c index 89fe4bb..3960b21 100644 --- a/Modules/_sqlite/statement.c +++ b/Modules/_sqlite/statement.c @@ -502,7 +502,8 @@ static PyType_Slot stmt_slots[] = { static PyType_Spec stmt_spec = { .name = MODULE_NAME ".Statement", .basicsize = sizeof(pysqlite_Statement), - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | + Py_TPFLAGS_IMMUTABLETYPE), .slots = stmt_slots, }; diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c index 3f7f1d2..bee69f2 100644 --- a/Modules/_threadmodule.c +++ b/Modules/_threadmodule.c @@ -313,7 +313,7 @@ static PyType_Spec lock_type_spec = { .name = "_thread.lock", .basicsize = sizeof(lockobject), .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_DISALLOW_INSTANTIATION), + Py_TPFLAGS_DISALLOW_INSTANTIATION | Py_TPFLAGS_IMMUTABLETYPE), .slots = lock_type_slots, }; @@ -594,7 +594,8 @@ static PyType_Slot rlock_type_slots[] = { static PyType_Spec rlock_type_spec = { .name = "_thread.RLock", .basicsize = sizeof(rlockobject), - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE), .slots = rlock_type_slots, }; @@ -693,7 +694,8 @@ static PyType_Slot local_dummy_type_slots[] = { static PyType_Spec local_dummy_type_spec = { .name = "_thread._localdummy", .basicsize = sizeof(localdummyobject), - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION | + Py_TPFLAGS_IMMUTABLETYPE), .slots = local_dummy_type_slots, }; @@ -977,7 +979,8 @@ static PyType_Slot local_type_slots[] = { static PyType_Spec local_type_spec = { .name = "_thread._local", .basicsize = sizeof(localobject), - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | + Py_TPFLAGS_IMMUTABLETYPE), .slots = local_type_slots, }; diff --git a/Modules/_winapi.c b/Modules/_winapi.c index 2c03462..1b85d7d 100644 --- a/Modules/_winapi.c +++ b/Modules/_winapi.c @@ -348,7 +348,7 @@ static PyType_Spec winapi_overlapped_type_spec = { .name = "_winapi.Overlapped", .basicsize = sizeof(OverlappedObject), .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION | - Py_TPFLAGS_HAVE_GC), + Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE), .slots = winapi_overlapped_type_slots, }; diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 30fb7c9..1d9d4cd 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -2997,7 +2997,7 @@ static PyType_Spec arrayiter_spec = { .name = "array.arrayiterator", .basicsize = sizeof(arrayiterobject), .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_DISALLOW_INSTANTIATION), + Py_TPFLAGS_DISALLOW_INSTANTIATION | Py_TPFLAGS_IMMUTABLETYPE), .slots = arrayiter_slots, }; diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c index cb7182f..ba558d0 100644 --- a/Modules/cjkcodecs/multibytecodec.c +++ b/Modules/cjkcodecs/multibytecodec.c @@ -749,7 +749,7 @@ static PyType_Spec multibytecodec_spec = { .name = MODULE_NAME ".MultibyteCodec", .basicsize = sizeof(MultibyteCodecObject), .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_DISALLOW_INSTANTIATION), + Py_TPFLAGS_DISALLOW_INSTANTIATION | Py_TPFLAGS_IMMUTABLETYPE), .slots = multibytecodec_slots, }; @@ -1111,7 +1111,8 @@ static PyType_Slot encoder_slots[] = { static PyType_Spec encoder_spec = { .name = MODULE_NAME ".MultibyteIncrementalEncoder", .basicsize = sizeof(MultibyteIncrementalEncoderObject), - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_IMMUTABLETYPE), .slots = encoder_slots, }; @@ -1384,7 +1385,8 @@ static PyType_Slot decoder_slots[] = { static PyType_Spec decoder_spec = { .name = MODULE_NAME ".MultibyteIncrementalDecoder", .basicsize = sizeof(MultibyteIncrementalDecoderObject), - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_IMMUTABLETYPE), .slots = decoder_slots, }; @@ -1705,7 +1707,8 @@ static PyType_Slot reader_slots[] = { static PyType_Spec reader_spec = { .name = MODULE_NAME ".MultibyteStreamReader", .basicsize = sizeof(MultibyteStreamReaderObject), - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_IMMUTABLETYPE), .slots = reader_slots, }; @@ -1925,7 +1928,8 @@ static PyType_Slot writer_slots[] = { static PyType_Spec writer_spec = { .name = MODULE_NAME ".MultibyteStreamWriter", .basicsize = sizeof(MultibyteStreamWriterObject), - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_IMMUTABLETYPE), .slots = writer_slots, }; diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index 8327ba6..6397b0d 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -1121,7 +1121,8 @@ static PyType_Slot mmap_object_slots[] = { static PyType_Spec mmap_object_spec = { .name = "mmap.mmap", .basicsize = sizeof(mmap_object), - .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC), + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE), .slots = mmap_object_slots, }; diff --git a/Modules/overlapped.c b/Modules/overlapped.c index 38dd98f..7c45708 100644 --- a/Modules/overlapped.c +++ b/Modules/overlapped.c @@ -1876,7 +1876,7 @@ static PyType_Slot overlapped_type_slots[] = { static PyType_Spec overlapped_type_spec = { .name = "_overlapped.Overlapped", .basicsize = sizeof(OverlappedObject), - .flags = Py_TPFLAGS_DEFAULT, + .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE), .slots = overlapped_type_slots }; diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index 9b04df3..ec68463 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -1504,7 +1504,7 @@ static PyType_Spec _xml_parse_type_spec = { .name = "pyexpat.xmlparser", .basicsize = sizeof(xmlparseobject), .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_DISALLOW_INSTANTIATION), + Py_TPFLAGS_DISALLOW_INSTANTIATION | Py_TPFLAGS_IMMUTABLETYPE), .slots = _xml_parse_type_spec_slots, }; diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c index a4b8193..26ac68b 100644 --- a/Modules/unicodedata.c +++ b/Modules/unicodedata.c @@ -1465,7 +1465,7 @@ static PyType_Spec ucd_type_spec = { .name = "unicodedata.UCD", .basicsize = sizeof(PreviousDBVersion), .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION | - Py_TPFLAGS_HAVE_GC), + Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE), .slots = ucd_type_slots }; -- cgit v0.12