bpo-42519: Replace PyObject_MALLOC() with PyObject_Malloc() (GH-23587)

No longer use deprecated aliases to functions:

* Replace PyObject_MALLOC() with PyObject_Malloc()
* Replace PyObject_REALLOC() with PyObject_Realloc()
* Replace PyObject_FREE() with PyObject_Free()
* Replace PyObject_Del() with PyObject_Free()
* Replace PyObject_DEL() with PyObject_Free()
diff --git a/Modules/_blake2/blake2b_impl.c b/Modules/_blake2/blake2b_impl.c
index 8e1acce..5d108ed 100644
--- a/Modules/_blake2/blake2b_impl.c
+++ b/Modules/_blake2/blake2b_impl.c
@@ -393,7 +393,7 @@ py_blake2b_dealloc(PyObject *self)
     }
 
     PyTypeObject *type = Py_TYPE(self);
-    PyObject_Del(self);
+    PyObject_Free(self);
     Py_DECREF(type);
 }
 
diff --git a/Modules/_blake2/blake2s_impl.c b/Modules/_blake2/blake2s_impl.c
index e1de5df..85c2d4e 100644
--- a/Modules/_blake2/blake2s_impl.c
+++ b/Modules/_blake2/blake2s_impl.c
@@ -392,7 +392,7 @@ py_blake2s_dealloc(PyObject *self)
     }
 
     PyTypeObject *type = Py_TYPE(self);
-    PyObject_Del(self);
+    PyObject_Free(self);
     Py_DECREF(type);
 }
 
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index 9b62987..40a05a4 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -475,7 +475,7 @@ static void
 PyCArg_dealloc(PyCArgObject *self)
 {
     Py_XDECREF(self->obj);
-    PyObject_Del(self);
+    PyObject_Free(self);
 }
 
 static int
diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c
index 1a8f0b6..7d25224 100644
--- a/Modules/_curses_panel.c
+++ b/Modules/_curses_panel.c
@@ -282,7 +282,7 @@ PyCursesPanel_Dealloc(PyCursesPanelObject *po)
         Py_DECREF(po->wo);
         remove_lop(po);
     }
-    PyObject_DEL(po);
+    PyObject_Free(po);
     Py_DECREF(tp);
 }
 
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index a598586..1f4789b 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -689,7 +689,7 @@ PyCursesWindow_Dealloc(PyCursesWindowObject *wo)
     if (wo->win != stdscr) delwin(wo->win);
     if (wo->encoding != NULL)
         PyMem_Free(wo->encoding);
-    PyObject_DEL(wo);
+    PyObject_Free(wo);
 }
 
 /* Addch, Addstr, Addnstr */
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c
index ea16c5a..9c85d76 100644
--- a/Modules/_decimal/_decimal.c
+++ b/Modules/_decimal/_decimal.c
@@ -1765,7 +1765,7 @@ ctxmanager_dealloc(PyDecContextManagerObject *self)
 {
     Py_XDECREF(self->local);
     Py_XDECREF(self->global);
-    PyObject_Del(self);
+    PyObject_Free(self);
 }
 
 static PyObject *
diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c
index 9fad21f..ff03c33 100644
--- a/Modules/_functoolsmodule.c
+++ b/Modules/_functoolsmodule.c
@@ -478,7 +478,7 @@ keyobject_dealloc(keyobject *ko)
 {
     Py_DECREF(ko->cmp);
     Py_XDECREF(ko->object);
-    PyObject_FREE(ko);
+    PyObject_Free(ko);
 }
 
 static int
@@ -742,7 +742,7 @@ lru_list_elem_dealloc(lru_list_elem *link)
 {
     Py_XDECREF(link->key);
     Py_XDECREF(link->result);
-    PyObject_Del(link);
+    PyObject_Free(link);
 }
 
 static PyTypeObject lru_list_elem_type = {
diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c
index 7e176cf..d4295d7 100644
--- a/Modules/_hashopenssl.c
+++ b/Modules/_hashopenssl.c
@@ -341,7 +341,7 @@ EVP_dealloc(EVPobject *self)
     if (self->lock != NULL)
         PyThread_free_lock(self->lock);
     EVP_MD_CTX_free(self->ctx);
-    PyObject_Del(self);
+    PyObject_Free(self);
     Py_DECREF(tp);
 }
 
@@ -1453,7 +1453,7 @@ _hashlib_hmac_new_impl(PyObject *module, Py_buffer *key, PyObject *msg_obj,
 
 error:
     if (ctx) HMAC_CTX_free(ctx);
-    if (self) PyObject_Del(self);
+    if (self) PyObject_Free(self);
     return NULL;
 }
 
@@ -1546,7 +1546,7 @@ _hmac_dealloc(HMACobject *self)
         PyThread_free_lock(self->lock);
     }
     HMAC_CTX_free(self->ctx);
-    PyObject_Del(self);
+    PyObject_Free(self);
     Py_DECREF(tp);
 }
 
diff --git a/Modules/_multiprocessing/semaphore.c b/Modules/_multiprocessing/semaphore.c
index 8732750..9a2d1f8 100644
--- a/Modules/_multiprocessing/semaphore.c
+++ b/Modules/_multiprocessing/semaphore.c
@@ -571,7 +571,7 @@ semlock_dealloc(SemLockObject* self)
     if (self->handle != SEM_FAILED)
         SEM_CLOSE(self->handle);
     PyMem_Free(self->name);
-    PyObject_Del(self);
+    PyObject_Free(self);
 }
 
 /*[clinic input]
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 7ecaeea..5a8aad9 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -443,7 +443,7 @@ Pdata_dealloc(Pdata *self)
         Py_DECREF(self->data[i]);
     }
     PyMem_Free(self->data);
-    PyObject_Del(self);
+    PyObject_Free(self);
 }
 
 static PyTypeObject Pdata_Type = {
diff --git a/Modules/_sha3/sha3module.c b/Modules/_sha3/sha3module.c
index da6dde6..cae10f9 100644
--- a/Modules/_sha3/sha3module.c
+++ b/Modules/_sha3/sha3module.c
@@ -274,7 +274,7 @@ SHA3_dealloc(SHA3object *self)
     }
 
     PyTypeObject *tp = Py_TYPE(self);
-    PyObject_Del(self);
+    PyObject_Free(self);
     Py_DECREF(tp);
 }
 
diff --git a/Modules/_sre.c b/Modules/_sre.c
index c67f38d..57faf7b 100644
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -571,7 +571,7 @@ pattern_dealloc(PatternObject* self)
     Py_XDECREF(self->pattern);
     Py_XDECREF(self->groupindex);
     Py_XDECREF(self->indexgroup);
-    PyObject_DEL(self);
+    PyObject_Free(self);
     Py_DECREF(tp);
 }
 
@@ -1944,7 +1944,7 @@ match_dealloc(MatchObject* self)
     Py_XDECREF(self->regs);
     Py_XDECREF(self->string);
     Py_DECREF(self->pattern);
-    PyObject_DEL(self);
+    PyObject_Free(self);
     Py_DECREF(tp);
 }
 
@@ -2450,7 +2450,7 @@ scanner_dealloc(ScannerObject* self)
 
     state_fini(&self->state);
     Py_XDECREF(self->pattern);
-    PyObject_DEL(self);
+    PyObject_Free(self);
     Py_DECREF(tp);
 }
 
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 87fe3a1..edb850e 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -2295,7 +2295,7 @@ PySSL_dealloc(PySSLSocket *self)
     Py_XDECREF(self->ctx);
     Py_XDECREF(self->server_hostname);
     Py_XDECREF(self->owner);
-    PyObject_Del(self);
+    PyObject_Free(self);
     Py_DECREF(tp);
 }
 
diff --git a/Modules/_testbuffer.c b/Modules/_testbuffer.c
index d832176..1b4fb09 100644
--- a/Modules/_testbuffer.c
+++ b/Modules/_testbuffer.c
@@ -236,7 +236,7 @@ ndarray_dealloc(NDArrayObject *self)
                 ndbuf_pop(self);
         }
     }
-    PyObject_Del(self);
+    PyObject_Free(self);
 }
 
 static int
@@ -2734,7 +2734,7 @@ staticarray_init(PyObject *self, PyObject *args, PyObject *kwds)
 static void
 staticarray_dealloc(StaticArrayObject *self)
 {
-    PyObject_Del(self);
+    PyObject_Free(self);
 }
 
 /* Return a buffer for a PyBUF_FULL_RO request. Flags are not checked,
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 916d10a..d210442 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -6010,7 +6010,7 @@ test_structmembers_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
 static void
 test_structmembers_free(PyObject *ob)
 {
-    PyObject_FREE(ob);
+    PyObject_Free(ob);
 }
 
 static PyTypeObject test_structmembersType = {
@@ -6664,7 +6664,7 @@ static void
 heapctype_dealloc(HeapCTypeObject *self)
 {
     PyTypeObject *tp = Py_TYPE(self);
-    PyObject_Del(self);
+    PyObject_Free(self);
     Py_DECREF(tp);
 }
 
@@ -6854,7 +6854,7 @@ heapctypewithdict_dealloc(HeapCTypeWithDictObject* self)
 
     PyTypeObject *tp = Py_TYPE(self);
     Py_XDECREF(self->dict);
-    PyObject_DEL(self);
+    PyObject_Free(self);
     Py_DECREF(tp);
 }
 
@@ -6925,7 +6925,7 @@ heapctypewithweakref_dealloc(HeapCTypeWithWeakrefObject* self)
     if (self->weakreflist != NULL)
         PyObject_ClearWeakRefs((PyObject *) self);
     Py_XDECREF(self->weakreflist);
-    PyObject_DEL(self);
+    PyObject_Free(self);
     Py_DECREF(tp);
 }
 
@@ -6968,7 +6968,7 @@ static void
 heapctypesetattr_dealloc(HeapCTypeSetattrObject *self)
 {
     PyTypeObject *tp = Py_TYPE(self);
-    PyObject_Del(self);
+    PyObject_Free(self);
     Py_DECREF(tp);
 }
 
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c
index dcefa8d..86d5f54 100644
--- a/Modules/_threadmodule.c
+++ b/Modules/_threadmodule.c
@@ -34,7 +34,7 @@ lock_dealloc(lockobject *self)
             PyThread_release_lock(self->lock_lock);
         PyThread_free_lock(self->lock_lock);
     }
-    PyObject_Del(self);
+    PyObject_Free(self);
 }
 
 /* Helper to acquire an interruptible lock with a timeout.  If the lock acquire
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index 24aeb3d..46d6a6e 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -904,7 +904,7 @@ PyTclObject_dealloc(PyTclObject *self)
     PyObject *tp = (PyObject *) Py_TYPE(self);
     Tcl_DecrRefCount(self->value);
     Py_XDECREF(self->string);
-    PyObject_Del(self);
+    PyObject_Free(self);
     Py_DECREF(tp);
 }
 
@@ -2823,7 +2823,7 @@ Tktt_Dealloc(PyObject *self)
 
     Py_XDECREF(func);
 
-    PyObject_Del(self);
+    PyObject_Free(self);
     Py_DECREF(tp);
 }
 
@@ -3096,7 +3096,7 @@ Tkapp_Dealloc(PyObject *self)
     ENTER_TCL
     Tcl_DeleteInterp(Tkapp_Interp(self));
     LEAVE_TCL
-    PyObject_Del(self);
+    PyObject_Free(self);
     Py_DECREF(tp);
     DisableEventHook();
 }
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c
index 37a80a7..9208b86 100644
--- a/Modules/cjkcodecs/multibytecodec.c
+++ b/Modules/cjkcodecs/multibytecodec.c
@@ -691,7 +691,7 @@ static struct PyMethodDef multibytecodec_methods[] = {
 static void
 multibytecodec_dealloc(MultibyteCodecObject *self)
 {
-    PyObject_Del(self);
+    PyObject_Free(self);
 }
 
 static PyTypeObject MultibyteCodec_Type = {
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index 4520143..fdbba6a 100644
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -2290,7 +2290,7 @@ _PyObject_GC_Resize(PyVarObject *op, Py_ssize_t nitems)
     }
 
     PyGC_Head *g = AS_GC(op);
-    g = (PyGC_Head *)PyObject_REALLOC(g,  sizeof(PyGC_Head) + basicsize);
+    g = (PyGC_Head *)PyObject_Realloc(g,  sizeof(PyGC_Head) + basicsize);
     if (g == NULL)
         return (PyVarObject *)PyErr_NoMemory();
     op = (PyVarObject *) FROM_GC(g);
@@ -2309,7 +2309,7 @@ PyObject_GC_Del(void *op)
     if (gcstate->generations[0].count > 0) {
         gcstate->generations[0].count--;
     }
-    PyObject_FREE(g);
+    PyObject_Free(g);
 }
 
 int
diff --git a/Modules/md5module.c b/Modules/md5module.c
index 9bd2bd1..1c401e8 100644
--- a/Modules/md5module.c
+++ b/Modules/md5module.c
@@ -342,7 +342,7 @@ static void
 MD5_dealloc(PyObject *ptr)
 {
     PyTypeObject *tp = Py_TYPE(ptr);
-    PyObject_Del(ptr);
+    PyObject_Free(ptr);
     Py_DECREF(tp);
 }
 
diff --git a/Modules/ossaudiodev.c b/Modules/ossaudiodev.c
index 2a1ac10..4f2d9cb 100644
--- a/Modules/ossaudiodev.c
+++ b/Modules/ossaudiodev.c
@@ -154,7 +154,7 @@ oss_dealloc(oss_audio_t *self)
     /* if already closed, don't reclose it */
     if (self->fd != -1)
         close(self->fd);
-    PyObject_Del(self);
+    PyObject_Free(self);
 }
 
 
@@ -199,7 +199,7 @@ oss_mixer_dealloc(oss_mixer_t *self)
     /* if already closed, don't reclose it */
     if (self->fd != -1)
         close(self->fd);
-    PyObject_Del(self);
+    PyObject_Free(self);
 }
 
 
diff --git a/Modules/overlapped.c b/Modules/overlapped.c
index 3829932..38dd98f 100644
--- a/Modules/overlapped.c
+++ b/Modules/overlapped.c
@@ -722,7 +722,7 @@ Overlapped_dealloc(OverlappedObject *self)
     SetLastError(olderr);
 
     PyTypeObject *tp = Py_TYPE(self);
-    PyObject_Del(self);
+    PyObject_Free(self);
     Py_DECREF(tp);
 }
 
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c
index 0b9f20d..f80da58 100644
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -742,7 +742,7 @@ poll_dealloc(pollObject *self)
     if (self->ufds != NULL)
         PyMem_Free(self->ufds);
     Py_XDECREF(self->dict);
-    PyObject_Del(self);
+    PyObject_Free(self);
     Py_DECREF(type);
 }
 
@@ -1130,7 +1130,7 @@ devpoll_dealloc(devpollObject *self)
     PyObject *type = (PyObject *)Py_TYPE(self);
     (void)devpoll_internal_close(self);
     PyMem_Free(self->fds);
-    PyObject_Del(self);
+    PyObject_Free(self);
     Py_DECREF(type);
 }
 
diff --git a/Modules/sha1module.c b/Modules/sha1module.c
index c22437d..52098570 100644
--- a/Modules/sha1module.c
+++ b/Modules/sha1module.c
@@ -320,7 +320,7 @@ static void
 SHA1_dealloc(PyObject *ptr)
 {
     PyTypeObject *tp = Py_TYPE(ptr);
-    PyObject_Del(ptr);
+    PyObject_Free(ptr);
     Py_DECREF(tp);
 }
 
diff --git a/Modules/sha256module.c b/Modules/sha256module.c
index edd4d01..6b8bd8f 100644
--- a/Modules/sha256module.c
+++ b/Modules/sha256module.c
@@ -397,7 +397,7 @@ static void
 SHA_dealloc(PyObject *ptr)
 {
     PyTypeObject *tp = Py_TYPE(ptr);
-    PyObject_Del(ptr);
+    PyObject_Free(ptr);
     Py_DECREF(tp);
 }
 
diff --git a/Modules/sha512module.c b/Modules/sha512module.c
index 725098d..3fd9fa4 100644
--- a/Modules/sha512module.c
+++ b/Modules/sha512module.c
@@ -453,7 +453,7 @@ static void
 SHA512_dealloc(PyObject *ptr)
 {
     PyTypeObject *tp = Py_TYPE(ptr);
-    PyObject_Del(ptr);
+    PyObject_Free(ptr);
     Py_DECREF(tp);
 }
 
diff --git a/Modules/sre_lib.h b/Modules/sre_lib.h
index cfe0a4a..322f66f 100644
--- a/Modules/sre_lib.h
+++ b/Modules/sre_lib.h
@@ -986,7 +986,7 @@ SRE(match)(SRE_STATE* state, const SRE_CODE* pattern, int toplevel)
                    ctx->pattern[1], ctx->pattern[2]));
 
             /* install new repeat context */
-            ctx->u.rep = (SRE_REPEAT*) PyObject_MALLOC(sizeof(*ctx->u.rep));
+            ctx->u.rep = (SRE_REPEAT*) PyObject_Malloc(sizeof(*ctx->u.rep));
             if (!ctx->u.rep) {
                 PyErr_NoMemory();
                 RETURN_FAILURE;
@@ -1000,7 +1000,7 @@ SRE(match)(SRE_STATE* state, const SRE_CODE* pattern, int toplevel)
             state->ptr = ctx->ptr;
             DO_JUMP(JUMP_REPEAT, jump_repeat, ctx->pattern+ctx->pattern[0]);
             state->repeat = ctx->u.rep->prev;
-            PyObject_FREE(ctx->u.rep);
+            PyObject_Free(ctx->u.rep);
 
             if (ret) {
                 RETURN_ON_ERROR(ret);
diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c
index fcf801d..4b8c46c 100644
--- a/Modules/unicodedata.c
+++ b/Modules/unicodedata.c
@@ -1418,7 +1418,7 @@ static void
 ucd_dealloc(PreviousDBVersion *self)
 {
     PyTypeObject *tp = Py_TYPE(self);
-    PyObject_Del(self);
+    PyObject_Free(self);
     Py_DECREF(tp);
 }
 
diff --git a/Modules/xxmodule.c b/Modules/xxmodule.c
index 17b049c..edcd621 100644
--- a/Modules/xxmodule.c
+++ b/Modules/xxmodule.c
@@ -44,7 +44,7 @@ static void
 Xxo_dealloc(XxoObject *self)
 {
     Py_XDECREF(self->x_attr);
-    PyObject_Del(self);
+    PyObject_Free(self);
 }
 
 static PyObject *
diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c
index def6176..a537087 100644
--- a/Modules/zlibmodule.c
+++ b/Modules/zlibmodule.c
@@ -591,7 +591,7 @@ Dealloc(compobject *self)
     Py_XDECREF(self->unused_data);
     Py_XDECREF(self->unconsumed_tail);
     Py_XDECREF(self->zdict);
-    PyObject_Del(self);
+    PyObject_Free(self);
     Py_DECREF(type);
 }