bpo-38142: Updated _hashopenssl.c to be PEP 384 compliant by tiran · Pull Request #16071 · python/cpython (original) (raw)

Since EVP is now a heap allocated type, you should now properly refcount the type as well. You can read the details in: https://docs.python.org/3.8/whatsnew/3.8.html#changes-in-the-c-api, search for bpo-35810

Anyways, the TL;DR is that EVP_dealloc should now be:

static void
EVP_dealloc(EVPobject *self)
{
    PyTypeObject *tp = Py_TYPE(self);
    if (self->lock != NULL)
        PyThread_free_lock(self->lock);
    EVP_MD_CTX_free(self->ctx);
    PyObject_Del(self);
    Py_DECREF(tp);
}