Skip to content

Commit 7297d74

Browse files
miss-islingtonErlend Egeberg Aasland
and
Erlend Egeberg Aasland
authored
bpo-43908: Make heap types converted during 3.10 alpha immutable (GH-26351) (GH-26766)
* 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 (cherry picked from commit 00710e6) Co-authored-by: Erlend Egeberg Aasland <[email protected]> Co-authored-by: Erlend Egeberg Aasland <[email protected]>
1 parent 08f2b9d commit 7297d74

22 files changed

+61
-38
lines changed

Modules/_bz2module.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ static PyType_Spec bz2_compressor_type_spec = {
422422
// bz2_compressor_type_spec does not have Py_TPFLAGS_BASETYPE flag
423423
// which prevents to create a subclass.
424424
// So calling PyType_GetModuleState() in this file is always safe.
425-
.flags = Py_TPFLAGS_DEFAULT,
425+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE),
426426
.slots = bz2_compressor_type_slots,
427427
};
428428

@@ -766,7 +766,7 @@ static PyType_Spec bz2_decompressor_type_spec = {
766766
// bz2_decompressor_type_spec does not have Py_TPFLAGS_BASETYPE flag
767767
// which prevents to create a subclass.
768768
// So calling PyType_GetModuleState() in this file is always safe.
769-
.flags = Py_TPFLAGS_DEFAULT,
769+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE),
770770
.slots = bz2_decompressor_type_slots,
771771
};
772772

Modules/_csv.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,8 @@ static PyType_Slot Dialect_Type_slots[] = {
537537
PyType_Spec Dialect_Type_spec = {
538538
.name = "_csv.Dialect",
539539
.basicsize = sizeof(DialectObj),
540-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
540+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
541+
Py_TPFLAGS_IMMUTABLETYPE),
541542
.slots = Dialect_Type_slots,
542543
};
543544

@@ -958,7 +959,8 @@ static PyType_Slot Reader_Type_slots[] = {
958959
PyType_Spec Reader_Type_spec = {
959960
.name = "_csv.reader",
960961
.basicsize = sizeof(ReaderObj),
961-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
962+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
963+
Py_TPFLAGS_IMMUTABLETYPE),
962964
.slots = Reader_Type_slots
963965
};
964966

@@ -1382,7 +1384,8 @@ static PyType_Slot Writer_Type_slots[] = {
13821384
PyType_Spec Writer_Type_spec = {
13831385
.name = "_csv.writer",
13841386
.basicsize = sizeof(WriterObj),
1385-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
1387+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
1388+
Py_TPFLAGS_IMMUTABLETYPE),
13861389
.slots = Writer_Type_slots,
13871390
};
13881391

Modules/_dbmmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ static PyType_Spec dbmtype_spec = {
424424
// which prevents to create a subclass.
425425
// So calling PyType_GetModuleState() in this file is always safe.
426426
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION |
427-
Py_TPFLAGS_HAVE_GC),
427+
Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE),
428428
.slots = dbmtype_spec_slots,
429429
};
430430

Modules/_functoolsmodule.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,8 @@ static PyType_Spec partial_type_spec = {
491491
.name = "functools.partial",
492492
.basicsize = sizeof(partialobject),
493493
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
494-
Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_VECTORCALL,
494+
Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_VECTORCALL |
495+
Py_TPFLAGS_IMMUTABLETYPE,
495496
.slots = partial_type_slots
496497
};
497498

@@ -559,7 +560,7 @@ static PyType_Spec keyobject_type_spec = {
559560
.name = "functools.KeyWrapper",
560561
.basicsize = sizeof(keyobject),
561562
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION |
562-
Py_TPFLAGS_HAVE_GC),
563+
Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE),
563564
.slots = keyobject_type_slots
564565
};
565566

@@ -781,7 +782,8 @@ static PyType_Slot lru_list_elem_type_slots[] = {
781782
static PyType_Spec lru_list_elem_type_spec = {
782783
.name = "functools._lru_list_elem",
783784
.basicsize = sizeof(lru_list_elem),
784-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION,
785+
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION |
786+
Py_TPFLAGS_IMMUTABLETYPE,
785787
.slots = lru_list_elem_type_slots
786788
};
787789

@@ -1417,7 +1419,7 @@ static PyType_Spec lru_cache_type_spec = {
14171419
.name = "functools._lru_cache_wrapper",
14181420
.basicsize = sizeof(lru_cache_object),
14191421
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
1420-
Py_TPFLAGS_METHOD_DESCRIPTOR,
1422+
Py_TPFLAGS_METHOD_DESCRIPTOR | Py_TPFLAGS_IMMUTABLETYPE,
14211423
.slots = lru_cache_type_slots
14221424
};
14231425

Modules/_gdbmmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ static PyType_Spec gdbmtype_spec = {
581581
// which prevents to create a subclass.
582582
// So calling PyType_GetModuleState() in this file is always safe.
583583
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION |
584-
Py_TPFLAGS_HAVE_GC),
584+
Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE),
585585
.slots = gdbmtype_spec_slots,
586586
};
587587

Modules/_lsprof.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,8 @@ static PyType_Slot _lsprof_profiler_type_spec_slots[] = {
812812
static PyType_Spec _lsprof_profiler_type_spec = {
813813
.name = "_lsprof.Profiler",
814814
.basicsize = sizeof(ProfilerObject),
815-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
815+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
816+
Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE),
816817
.slots = _lsprof_profiler_type_spec_slots,
817818
};
818819

Modules/_lzmamodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ static PyType_Spec lzma_compressor_type_spec = {
915915
// lzma_compressor_type_spec does not have Py_TPFLAGS_BASETYPE flag
916916
// which prevents to create a subclass.
917917
// So calling PyType_GetModuleState() in this file is always safe.
918-
.flags = Py_TPFLAGS_DEFAULT,
918+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE),
919919
.slots = lzma_compressor_type_slots,
920920
};
921921

@@ -1359,7 +1359,7 @@ static PyType_Spec lzma_decompressor_type_spec = {
13591359
// lzma_decompressor_type_spec does not have Py_TPFLAGS_BASETYPE flag
13601360
// which prevents to create a subclass.
13611361
// So calling PyType_GetModuleState() in this file is always safe.
1362-
.flags = Py_TPFLAGS_DEFAULT,
1362+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE),
13631363
.slots = lzma_decompressor_type_slots,
13641364
};
13651365

Modules/_operator.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,8 @@ static PyType_Spec itemgetter_type_spec = {
11331133
.name = "operator.itemgetter",
11341134
.basicsize = sizeof(itemgetterobject),
11351135
.itemsize = 0,
1136-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
1136+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
1137+
Py_TPFLAGS_IMMUTABLETYPE),
11371138
.slots = itemgetter_type_slots,
11381139
};
11391140

@@ -1464,7 +1465,8 @@ static PyType_Spec attrgetter_type_spec = {
14641465
.name = "operator.attrgetter",
14651466
.basicsize = sizeof(attrgetterobject),
14661467
.itemsize = 0,
1467-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
1468+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
1469+
Py_TPFLAGS_IMMUTABLETYPE),
14681470
.slots = attrgetter_type_slots,
14691471
};
14701472

@@ -1719,7 +1721,8 @@ static PyType_Spec methodcaller_type_spec = {
17191721
.name = "operator.methodcaller",
17201722
.basicsize = sizeof(methodcallerobject),
17211723
.itemsize = 0,
1722-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
1724+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
1725+
Py_TPFLAGS_IMMUTABLETYPE),
17231726
.slots = methodcaller_type_slots,
17241727
};
17251728

Modules/_queuemodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@ static PyType_Slot simplequeue_slots[] = {
380380
static PyType_Spec simplequeue_spec = {
381381
.name = "_queue.SimpleQueue",
382382
.basicsize = sizeof(simplequeueobject),
383-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
383+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
384+
Py_TPFLAGS_IMMUTABLETYPE),
384385
.slots = simplequeue_slots,
385386
};
386387

Modules/_sqlite/connection.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1934,7 +1934,8 @@ static PyType_Slot connection_slots[] = {
19341934
static PyType_Spec connection_spec = {
19351935
.name = MODULE_NAME ".Connection",
19361936
.basicsize = sizeof(pysqlite_Connection),
1937-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
1937+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
1938+
Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE),
19381939
.slots = connection_slots,
19391940
};
19401941

Modules/_sqlite/cursor.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,8 @@ static PyType_Slot cursor_slots[] = {
10361036
static PyType_Spec cursor_spec = {
10371037
.name = MODULE_NAME ".Cursor",
10381038
.basicsize = sizeof(pysqlite_Cursor),
1039-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
1039+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
1040+
Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE),
10401041
.slots = cursor_slots,
10411042
};
10421043

Modules/_sqlite/prepare_protocol.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ static PyType_Slot type_slots[] = {
5656
static PyType_Spec type_spec = {
5757
.name = MODULE_NAME ".PrepareProtocol",
5858
.basicsize = sizeof(pysqlite_PrepareProtocol),
59-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
59+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
60+
Py_TPFLAGS_IMMUTABLETYPE),
6061
.slots = type_slots,
6162
};
6263

Modules/_sqlite/row.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ static PyType_Slot row_slots[] = {
254254
static PyType_Spec row_spec = {
255255
.name = MODULE_NAME ".Row",
256256
.basicsize = sizeof(pysqlite_Row),
257-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
257+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
258+
Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE),
258259
.slots = row_slots,
259260
};
260261

Modules/_sqlite/statement.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,8 @@ static PyType_Slot stmt_slots[] = {
508508
static PyType_Spec stmt_spec = {
509509
.name = MODULE_NAME ".Statement",
510510
.basicsize = sizeof(pysqlite_Statement),
511-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
511+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
512+
Py_TPFLAGS_IMMUTABLETYPE),
512513
.slots = stmt_slots,
513514
};
514515
PyTypeObject *pysqlite_StatementType = NULL;

Modules/_threadmodule.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ static PyType_Spec lock_type_spec = {
313313
.name = "_thread.lock",
314314
.basicsize = sizeof(lockobject),
315315
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
316-
Py_TPFLAGS_DISALLOW_INSTANTIATION),
316+
Py_TPFLAGS_DISALLOW_INSTANTIATION | Py_TPFLAGS_IMMUTABLETYPE),
317317
.slots = lock_type_slots,
318318
};
319319

@@ -594,7 +594,8 @@ static PyType_Slot rlock_type_slots[] = {
594594
static PyType_Spec rlock_type_spec = {
595595
.name = "_thread.RLock",
596596
.basicsize = sizeof(rlockobject),
597-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,
597+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
598+
Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE),
598599
.slots = rlock_type_slots,
599600
};
600601

@@ -693,7 +694,8 @@ static PyType_Slot local_dummy_type_slots[] = {
693694
static PyType_Spec local_dummy_type_spec = {
694695
.name = "_thread._localdummy",
695696
.basicsize = sizeof(localdummyobject),
696-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION,
697+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION |
698+
Py_TPFLAGS_IMMUTABLETYPE),
697699
.slots = local_dummy_type_slots,
698700
};
699701

@@ -977,7 +979,8 @@ static PyType_Slot local_type_slots[] = {
977979
static PyType_Spec local_type_spec = {
978980
.name = "_thread._local",
979981
.basicsize = sizeof(localobject),
980-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
982+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
983+
Py_TPFLAGS_IMMUTABLETYPE),
981984
.slots = local_type_slots,
982985
};
983986

Modules/_winapi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static PyType_Spec winapi_overlapped_type_spec = {
348348
.name = "_winapi.Overlapped",
349349
.basicsize = sizeof(OverlappedObject),
350350
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION |
351-
Py_TPFLAGS_HAVE_GC),
351+
Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE),
352352
.slots = winapi_overlapped_type_slots,
353353
};
354354

Modules/arraymodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2997,7 +2997,7 @@ static PyType_Spec arrayiter_spec = {
29972997
.name = "array.arrayiterator",
29982998
.basicsize = sizeof(arrayiterobject),
29992999
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
3000-
Py_TPFLAGS_DISALLOW_INSTANTIATION),
3000+
Py_TPFLAGS_DISALLOW_INSTANTIATION | Py_TPFLAGS_IMMUTABLETYPE),
30013001
.slots = arrayiter_slots,
30023002
};
30033003

Modules/cjkcodecs/multibytecodec.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ static PyType_Spec multibytecodec_spec = {
749749
.name = MODULE_NAME ".MultibyteCodec",
750750
.basicsize = sizeof(MultibyteCodecObject),
751751
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
752-
Py_TPFLAGS_DISALLOW_INSTANTIATION),
752+
Py_TPFLAGS_DISALLOW_INSTANTIATION | Py_TPFLAGS_IMMUTABLETYPE),
753753
.slots = multibytecodec_slots,
754754
};
755755

@@ -1111,7 +1111,8 @@ static PyType_Slot encoder_slots[] = {
11111111
static PyType_Spec encoder_spec = {
11121112
.name = MODULE_NAME ".MultibyteIncrementalEncoder",
11131113
.basicsize = sizeof(MultibyteIncrementalEncoderObject),
1114-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,
1114+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE |
1115+
Py_TPFLAGS_IMMUTABLETYPE),
11151116
.slots = encoder_slots,
11161117
};
11171118

@@ -1384,7 +1385,8 @@ static PyType_Slot decoder_slots[] = {
13841385
static PyType_Spec decoder_spec = {
13851386
.name = MODULE_NAME ".MultibyteIncrementalDecoder",
13861387
.basicsize = sizeof(MultibyteIncrementalDecoderObject),
1387-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,
1388+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE |
1389+
Py_TPFLAGS_IMMUTABLETYPE),
13881390
.slots = decoder_slots,
13891391
};
13901392

@@ -1705,7 +1707,8 @@ static PyType_Slot reader_slots[] = {
17051707
static PyType_Spec reader_spec = {
17061708
.name = MODULE_NAME ".MultibyteStreamReader",
17071709
.basicsize = sizeof(MultibyteStreamReaderObject),
1708-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,
1710+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE |
1711+
Py_TPFLAGS_IMMUTABLETYPE),
17091712
.slots = reader_slots,
17101713
};
17111714

@@ -1925,7 +1928,8 @@ static PyType_Slot writer_slots[] = {
19251928
static PyType_Spec writer_spec = {
19261929
.name = MODULE_NAME ".MultibyteStreamWriter",
19271930
.basicsize = sizeof(MultibyteStreamWriterObject),
1928-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,
1931+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE |
1932+
Py_TPFLAGS_IMMUTABLETYPE),
19291933
.slots = writer_slots,
19301934
};
19311935

Modules/mmapmodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,8 @@ static PyType_Slot mmap_object_slots[] = {
11211121
static PyType_Spec mmap_object_spec = {
11221122
.name = "mmap.mmap",
11231123
.basicsize = sizeof(mmap_object),
1124-
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC),
1124+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
1125+
Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE),
11251126
.slots = mmap_object_slots,
11261127
};
11271128

Modules/overlapped.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1876,7 +1876,7 @@ static PyType_Slot overlapped_type_slots[] = {
18761876
static PyType_Spec overlapped_type_spec = {
18771877
.name = "_overlapped.Overlapped",
18781878
.basicsize = sizeof(OverlappedObject),
1879-
.flags = Py_TPFLAGS_DEFAULT,
1879+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE),
18801880
.slots = overlapped_type_slots
18811881
};
18821882

Modules/pyexpat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,7 @@ static PyType_Spec _xml_parse_type_spec = {
15041504
.name = "pyexpat.xmlparser",
15051505
.basicsize = sizeof(xmlparseobject),
15061506
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
1507-
Py_TPFLAGS_DISALLOW_INSTANTIATION),
1507+
Py_TPFLAGS_DISALLOW_INSTANTIATION | Py_TPFLAGS_IMMUTABLETYPE),
15081508
.slots = _xml_parse_type_spec_slots,
15091509
};
15101510

Modules/unicodedata.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1465,7 +1465,7 @@ static PyType_Spec ucd_type_spec = {
14651465
.name = "unicodedata.UCD",
14661466
.basicsize = sizeof(PreviousDBVersion),
14671467
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION |
1468-
Py_TPFLAGS_HAVE_GC),
1468+
Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE),
14691469
.slots = ucd_type_slots
14701470
};
14711471

0 commit comments

Comments
 (0)