@@ -752,7 +752,9 @@ py_wrapper_EVP_MD_CTX_new(void)
752752static HASHobject *
753753new_hash_object (PyTypeObject * type )
754754{
755- HASHobject * retval = PyObject_GC_New (HASHobject , type );
755+ assert (type != NULL );
756+ assert (type -> tp_alloc != NULL );
757+ HASHobject * retval = (HASHobject * )type -> tp_alloc (type , 0 );
756758 if (retval == NULL ) {
757759 return NULL ;
758760 }
@@ -764,7 +766,6 @@ new_hash_object(PyTypeObject *type)
764766 return NULL ;
765767 }
766768
767- PyObject_GC_Track (retval );
768769 return retval ;
769770}
770771
@@ -797,7 +798,7 @@ _hashlib_HASH_dealloc(PyObject *op)
797798 PyObject_GC_UnTrack (op );
798799 HASHobject * self = HASHobject_CAST (op );
799800 EVP_MD_CTX_free (self -> ctx );
800- PyObject_GC_Del (self );
801+ tp -> tp_free (self );
801802 Py_DECREF (tp );
802803}
803804
@@ -1176,7 +1177,7 @@ PyDoc_STRVAR(HASHXOFobject_type_doc,
11761177"digest_size -- number of bytes in this hashes output" );
11771178
11781179static PyType_Slot HASHXOFobject_type_slots [] = {
1179- /* tp_dealloc is inherited from _hashlib.HASH */
1180+ { Py_tp_dealloc , _hashlib_HASH_dealloc },
11801181 {Py_tp_traverse , _hashlib_HASH_traverse },
11811182 {Py_tp_doc , (char * )HASHXOFobject_type_doc },
11821183 {Py_tp_methods , HASHXOFobject_methods },
@@ -1916,15 +1917,15 @@ _hashlib_hmac_new_impl(PyObject *module, Py_buffer *key, PyObject *msg_obj,
19161917 goto error ;
19171918 }
19181919
1919- self = PyObject_GC_New (HMACobject , state -> HMAC_type );
1920+ assert (state -> HMAC_type != NULL );
1921+ self = (HMACobject * )state -> HMAC_type -> tp_alloc (state -> HMAC_type , 0 );
19201922 if (self == NULL ) {
19211923 goto error ;
19221924 }
19231925
19241926 self -> ctx = ctx ;
19251927 ctx = NULL ; // 'ctx' is now owned by 'self'
19261928 HASHLIB_INIT_MUTEX (self );
1927- PyObject_GC_Track (self );
19281929
19291930 if ((msg_obj != NULL ) && (msg_obj != Py_None )) {
19301931 if (!_hmac_update (self , msg_obj )) {
@@ -2023,15 +2024,15 @@ _hashlib_HMAC_copy_impl(HMACobject *self)
20232024 return NULL ;
20242025 }
20252026
2026- retval = PyObject_GC_New (HMACobject , Py_TYPE (self ));
2027+ PyTypeObject * type = Py_TYPE (self );
2028+ retval = (HMACobject * )type -> tp_alloc (type , 0 );
20272029 if (retval == NULL ) {
20282030 HMAC_CTX_free (ctx );
20292031 return NULL ;
20302032 }
20312033 retval -> ctx = ctx ;
20322034 HASHLIB_INIT_MUTEX (retval );
20332035
2034- PyObject_GC_Track (retval );
20352036 return (PyObject * )retval ;
20362037}
20372038
@@ -2045,7 +2046,7 @@ _hmac_dealloc(PyObject *op)
20452046 HMAC_CTX_free (self -> ctx );
20462047 self -> ctx = NULL ;
20472048 }
2048- PyObject_GC_Del (self );
2049+ tp -> tp_free (self );
20492050 Py_DECREF (tp );
20502051}
20512052
0 commit comments