Skip to content

Commit d77b19c

Browse files
Remove gc-support from some immutable types
1 parent e92599e commit d77b19c

File tree

5 files changed

+5
-48
lines changed

5 files changed

+5
-48
lines changed

Modules/_bz2module.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -391,13 +391,6 @@ BZ2Compressor_dealloc(PyObject *op)
391391
Py_DECREF(tp);
392392
}
393393

394-
static int
395-
BZ2Compressor_traverse(PyObject *self, visitproc visit, void *arg)
396-
{
397-
Py_VISIT(Py_TYPE(self));
398-
return 0;
399-
}
400-
401394
static PyMethodDef BZ2Compressor_methods[] = {
402395
_BZ2_BZ2COMPRESSOR_COMPRESS_METHODDEF
403396
_BZ2_BZ2COMPRESSOR_FLUSH_METHODDEF
@@ -409,7 +402,6 @@ static PyType_Slot bz2_compressor_type_slots[] = {
409402
{Py_tp_methods, BZ2Compressor_methods},
410403
{Py_tp_new, _bz2_BZ2Compressor},
411404
{Py_tp_doc, (char *)_bz2_BZ2Compressor__doc__},
412-
{Py_tp_traverse, BZ2Compressor_traverse},
413405
{0, 0}
414406
};
415407

@@ -701,13 +693,6 @@ BZ2Decompressor_dealloc(PyObject *op)
701693
Py_DECREF(tp);
702694
}
703695

704-
static int
705-
BZ2Decompressor_traverse(PyObject *self, visitproc visit, void *arg)
706-
{
707-
Py_VISIT(Py_TYPE(self));
708-
return 0;
709-
}
710-
711696
static PyMethodDef BZ2Decompressor_methods[] = {
712697
_BZ2_BZ2DECOMPRESSOR_DECOMPRESS_METHODDEF
713698
{NULL}
@@ -738,7 +723,6 @@ static PyType_Slot bz2_decompressor_type_slots[] = {
738723
{Py_tp_doc, (char *)_bz2_BZ2Decompressor__doc__},
739724
{Py_tp_members, BZ2Decompressor_members},
740725
{Py_tp_new, _bz2_BZ2Decompressor},
741-
{Py_tp_traverse, BZ2Decompressor_traverse},
742726
{0, 0}
743727
};
744728

Modules/_lzmamodule.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -882,13 +882,6 @@ static PyMethodDef Compressor_methods[] = {
882882
{NULL}
883883
};
884884

885-
static int
886-
Compressor_traverse(PyObject *self, visitproc visit, void *arg)
887-
{
888-
Py_VISIT(Py_TYPE(self));
889-
return 0;
890-
}
891-
892885
PyDoc_STRVAR(Compressor_doc,
893886
"LZMACompressor(format=FORMAT_XZ, check=-1, preset=None, filters=None)\n"
894887
"\n"
@@ -922,7 +915,6 @@ static PyType_Slot lzma_compressor_type_slots[] = {
922915
{Py_tp_methods, Compressor_methods},
923916
{Py_tp_new, Compressor_new},
924917
{Py_tp_doc, (char *)Compressor_doc},
925-
{Py_tp_traverse, Compressor_traverse},
926918
{0, 0}
927919
};
928920

@@ -1325,13 +1317,6 @@ Decompressor_dealloc(PyObject *op)
13251317
Py_DECREF(tp);
13261318
}
13271319

1328-
static int
1329-
Decompressor_traverse(PyObject *self, visitproc visit, void *arg)
1330-
{
1331-
Py_VISIT(Py_TYPE(self));
1332-
return 0;
1333-
}
1334-
13351320
static PyMethodDef Decompressor_methods[] = {
13361321
_LZMA_LZMADECOMPRESSOR_DECOMPRESS_METHODDEF
13371322
{NULL}
@@ -1366,7 +1351,6 @@ static PyType_Slot lzma_decompressor_type_slots[] = {
13661351
{Py_tp_methods, Decompressor_methods},
13671352
{Py_tp_new, _lzma_LZMADecompressor},
13681353
{Py_tp_doc, (char *)_lzma_LZMADecompressor__doc__},
1369-
{Py_tp_traverse, Decompressor_traverse},
13701354
{Py_tp_members, Decompressor_members},
13711355
{0, 0}
13721356
};

Modules/_ssl.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5791,7 +5791,6 @@ memory_bio_dealloc(PyObject *op)
57915791
{
57925792
PySSLMemoryBIO *self = PySSLMemoryBIO_CAST(op);
57935793
PyTypeObject *tp = Py_TYPE(self);
5794-
PyObject_GC_UnTrack(self);
57955794
(void)BIO_free(self->bio);
57965795
tp->tp_free(self);
57975796
Py_DECREF(tp);
@@ -5956,15 +5955,13 @@ static PyType_Slot PySSLMemoryBIO_slots[] = {
59565955
{Py_tp_getset, memory_bio_getsetlist},
59575956
{Py_tp_new, _ssl_MemoryBIO},
59585957
{Py_tp_dealloc, memory_bio_dealloc},
5959-
{Py_tp_traverse, _PyObject_VisitType},
59605958
{0, 0},
59615959
};
59625960

59635961
static PyType_Spec PySSLMemoryBIO_spec = {
59645962
.name = "_ssl.MemoryBIO",
59655963
.basicsize = sizeof(PySSLMemoryBIO),
5966-
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE |
5967-
Py_TPFLAGS_HAVE_GC),
5964+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE),
59685965
.slots = PySSLMemoryBIO_slots,
59695966
};
59705967

Modules/_threadmodule.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,6 @@ static void
659659
PyThreadHandleObject_dealloc(PyObject *op)
660660
{
661661
PyThreadHandleObject *self = PyThreadHandleObject_CAST(op);
662-
PyObject_GC_UnTrack(self);
663662
PyTypeObject *tp = Py_TYPE(self);
664663
ThreadHandle_decref(self->handle);
665664
tp->tp_free(self);
@@ -747,7 +746,6 @@ static PyType_Slot ThreadHandle_Type_slots[] = {
747746
{Py_tp_dealloc, PyThreadHandleObject_dealloc},
748747
{Py_tp_repr, PyThreadHandleObject_repr},
749748
{Py_tp_getset, ThreadHandle_getsetlist},
750-
{Py_tp_traverse, _PyObject_VisitType},
751749
{Py_tp_methods, ThreadHandle_methods},
752750
{Py_tp_new, PyThreadHandleObject_tp_new},
753751
{0, 0}
@@ -757,7 +755,7 @@ static PyType_Spec ThreadHandle_Type_spec = {
757755
"_thread._ThreadHandle",
758756
sizeof(PyThreadHandleObject),
759757
0,
760-
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_HAVE_GC,
758+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE,
761759
ThreadHandle_Type_slots,
762760
};
763761

Modules/hmacmodule.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ _hmac_new_impl(PyObject *module, PyObject *keyobj, PyObject *msgobj,
756756
return NULL;
757757
}
758758

759-
HMACObject *self = PyObject_GC_New(HMACObject, state->hmac_type);
759+
HMACObject *self = PyObject_New(HMACObject, state->hmac_type);
760760
if (self == NULL) {
761761
return NULL;
762762
}
@@ -791,7 +791,6 @@ _hmac_new_impl(PyObject *module, PyObject *keyobj, PyObject *msgobj,
791791
#endif
792792
}
793793
assert(rc == 0);
794-
PyObject_GC_Track(self);
795794
return (PyObject *)self;
796795

797796
error_on_key:
@@ -852,7 +851,7 @@ _hmac_HMAC_copy_impl(HMACObject *self, PyTypeObject *cls)
852851
/*[clinic end generated code: output=a955bfa55b65b215 input=17b2c0ad0b147e36]*/
853852
{
854853
hmacmodule_state *state = get_hmacmodule_state_by_cls(cls);
855-
HMACObject *copy = PyObject_GC_New(HMACObject, state->hmac_type);
854+
HMACObject *copy = PyObject_New(HMACObject, state->hmac_type);
856855
if (copy == NULL) {
857856
return NULL;
858857
}
@@ -870,7 +869,6 @@ _hmac_HMAC_copy_impl(HMACObject *self, PyTypeObject *cls)
870869
}
871870

872871
HASHLIB_INIT_MUTEX(copy);
873-
PyObject_GC_Track(copy);
874872
return (PyObject *)copy;
875873
}
876874

@@ -1026,7 +1024,6 @@ static void
10261024
HMACObject_dealloc(PyObject *op)
10271025
{
10281026
PyTypeObject *type = Py_TYPE(op);
1029-
PyObject_GC_UnTrack(op);
10301027
(void)HMACObject_clear(op);
10311028
type->tp_free(op);
10321029
Py_DECREF(type);
@@ -1051,9 +1048,7 @@ static PyType_Slot HMACObject_Type_slots[] = {
10511048
{Py_tp_repr, HMACObject_repr},
10521049
{Py_tp_methods, HMACObject_methods},
10531050
{Py_tp_getset, HMACObject_getsets},
1054-
{Py_tp_clear, HMACObject_clear},
10551051
{Py_tp_dealloc, HMACObject_dealloc},
1056-
{Py_tp_traverse, _PyObject_VisitType},
10571052
{0, NULL} /* sentinel */
10581053
};
10591054

@@ -1063,8 +1058,7 @@ static PyType_Spec HMAC_Type_spec = {
10631058
.flags = Py_TPFLAGS_DEFAULT
10641059
| Py_TPFLAGS_DISALLOW_INSTANTIATION
10651060
| Py_TPFLAGS_HEAPTYPE
1066-
| Py_TPFLAGS_IMMUTABLETYPE
1067-
| Py_TPFLAGS_HAVE_GC,
1061+
| Py_TPFLAGS_IMMUTABLETYPE,
10681062
.slots = HMACObject_Type_slots,
10691063
};
10701064

0 commit comments

Comments
 (0)