From 8a6fcab6af74ea4f0ca8414ac0a150c4a94c9ca3 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 26 Aug 2019 23:42:41 +0200 Subject: [PATCH] Make PyXXX_Fini() functions private For example, rename PyTuple_Fini() to _PyTuple_Fini(). These functions are only declared in the internal C API. --- Include/internal/pycore_pylifecycle.h | 25 +++++++++++++------------ Objects/bytesobject.c | 2 +- Objects/classobject.c | 2 +- Objects/dictobject.c | 2 +- Objects/floatobject.c | 2 +- Objects/frameobject.c | 2 +- Objects/genobject.c | 2 +- Objects/listobject.c | 2 +- Objects/longobject.c | 2 +- Objects/methodobject.c | 2 +- Objects/setobject.c | 2 +- Objects/sliceobject.c | 3 ++- Objects/tupleobject.c | 2 +- Python/pylifecycle.c | 24 ++++++++++++------------ 14 files changed, 38 insertions(+), 36 deletions(-) diff --git a/Include/internal/pycore_pylifecycle.h b/Include/internal/pycore_pylifecycle.h index bdc4bf5a46d4f9..49574295943314 100644 --- a/Include/internal/pycore_pylifecycle.h +++ b/Include/internal/pycore_pylifecycle.h @@ -62,18 +62,19 @@ extern PyStatus _PyImportZip_Init(PyThreadState *tstate); /* Various internal finalizers */ -extern void PyMethod_Fini(void); -extern void PyFrame_Fini(void); -extern void PyCFunction_Fini(void); -extern void PyDict_Fini(void); -extern void PyTuple_Fini(void); -extern void PyList_Fini(void); -extern void PySet_Fini(void); -extern void PyBytes_Fini(void); -extern void PyFloat_Fini(void); +extern void _PyMethod_Fini(void); +extern void _PyFrame_Fini(void); +extern void _PyCFunction_Fini(void); +extern void _PyDict_Fini(void); +extern void _PyTuple_Fini(void); +extern void _PyList_Fini(void); +extern void _PySet_Fini(void); +extern void _PyBytes_Fini(void); +extern void _PyFloat_Fini(void); +extern void _PySlice_Fini(void); +extern void _PyAsyncGen_Fini(void); + extern void PyOS_FiniInterrupts(void); -extern void PySlice_Fini(void); -extern void PyAsyncGen_Fini(void); extern void _PyExc_Fini(void); extern void _PyImport_Fini(void); @@ -82,7 +83,7 @@ extern void _PyGC_Fini(_PyRuntimeState *runtime); extern void _PyType_Fini(void); extern void _Py_HashRandomization_Fini(void); extern void _PyUnicode_Fini(void); -extern void PyLong_Fini(void); +extern void _PyLong_Fini(void); extern void _PyFaulthandler_Fini(void); extern void _PyHash_Fini(void); extern int _PyTraceMalloc_Fini(void); diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index c4edcca4f76127..6d553304a403ff 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -3047,7 +3047,7 @@ _PyBytes_Resize(PyObject **pv, Py_ssize_t newsize) } void -PyBytes_Fini(void) +_PyBytes_Fini(void) { int i; for (i = 0; i < UCHAR_MAX + 1; i++) diff --git a/Objects/classobject.c b/Objects/classobject.c index 40cbeaa9f2aaca..4a9add1229e374 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -375,7 +375,7 @@ PyMethod_ClearFreeList(void) } void -PyMethod_Fini(void) +_PyMethod_Fini(void) { (void)PyMethod_ClearFreeList(); } diff --git a/Objects/dictobject.c b/Objects/dictobject.c index fec3a87e9f5de7..73956df4ab2a5b 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -282,7 +282,7 @@ _PyDict_DebugMallocStats(FILE *out) void -PyDict_Fini(void) +_PyDict_Fini(void) { PyDict_ClearFreeList(); } diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 689e92907d037f..6643ff340ea5de 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -2031,7 +2031,7 @@ PyFloat_ClearFreeList(void) } void -PyFloat_Fini(void) +_PyFloat_Fini(void) { (void)PyFloat_ClearFreeList(); } diff --git a/Objects/frameobject.c b/Objects/frameobject.c index a796a59eee9e40..27ef9ff2590248 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -997,7 +997,7 @@ PyFrame_ClearFreeList(void) } void -PyFrame_Fini(void) +_PyFrame_Fini(void) { (void)PyFrame_ClearFreeList(); } diff --git a/Objects/genobject.c b/Objects/genobject.c index 5d1f9c7dd13e1c..5e0bfa4f43de5b 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -1463,7 +1463,7 @@ PyAsyncGen_ClearFreeLists(void) } void -PyAsyncGen_Fini(void) +_PyAsyncGen_Fini(void) { PyAsyncGen_ClearFreeLists(); } diff --git a/Objects/listobject.c b/Objects/listobject.c index cea9b24a3b2fb6..5fca08ea363a41 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -138,7 +138,7 @@ PyList_ClearFreeList(void) } void -PyList_Fini(void) +_PyList_Fini(void) { PyList_ClearFreeList(); } diff --git a/Objects/longobject.c b/Objects/longobject.c index 74037be7a1ea3f..475b9bda59f93b 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -5869,7 +5869,7 @@ _PyLong_Init(void) } void -PyLong_Fini(void) +_PyLong_Fini(void) { /* Integers are currently statically allocated. Py_DECREF is not needed, but Python must forget about the reference or multiple diff --git a/Objects/methodobject.c b/Objects/methodobject.c index b9977467ac08d5..7d70cc04a23805 100644 --- a/Objects/methodobject.c +++ b/Objects/methodobject.c @@ -319,7 +319,7 @@ PyCFunction_ClearFreeList(void) } void -PyCFunction_Fini(void) +_PyCFunction_Fini(void) { (void)PyCFunction_ClearFreeList(); } diff --git a/Objects/setobject.c b/Objects/setobject.c index 8cd95ba890dd5f..56858dbccfe158 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -2318,7 +2318,7 @@ PySet_ClearFreeList(void) } void -PySet_Fini(void) +_PySet_Fini(void) { Py_CLEAR(emptyfrozenset); } diff --git a/Objects/sliceobject.c b/Objects/sliceobject.c index 7c10eb6f638d3a..e884a58943562c 100644 --- a/Objects/sliceobject.c +++ b/Objects/sliceobject.c @@ -100,7 +100,8 @@ PyObject _Py_EllipsisObject = { * created and then deleted again */ static PySliceObject *slice_cache = NULL; -void PySlice_Fini(void) + +void _PySlice_Fini(void) { PySliceObject *obj = slice_cache; if (obj != NULL) { diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index 79a5d55749be85..3419baa529a6f0 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -989,7 +989,7 @@ PyTuple_ClearFreeList(void) } void -PyTuple_Fini(void) +_PyTuple_Fini(void) { #if PyTuple_MAXSAVESIZE > 0 /* empty tuples are used all over the place and applications may diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index e3333db4328ae6..7cda44dc29d38b 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -1307,22 +1307,22 @@ Py_FinalizeEx(void) _PyExc_Fini(); /* Sundry finalizers */ - PyMethod_Fini(); - PyFrame_Fini(); - PyCFunction_Fini(); - PyTuple_Fini(); - PyList_Fini(); - PySet_Fini(); - PyBytes_Fini(); - PyLong_Fini(); - PyFloat_Fini(); - PyDict_Fini(); - PySlice_Fini(); + _PyMethod_Fini(); + _PyFrame_Fini(); + _PyCFunction_Fini(); + _PyTuple_Fini(); + _PyList_Fini(); + _PySet_Fini(); + _PyBytes_Fini(); + _PyLong_Fini(); + _PyFloat_Fini(); + _PyDict_Fini(); + _PySlice_Fini(); _PyGC_Fini(runtime); _PyWarnings_Fini(interp); _Py_HashRandomization_Fini(); _PyArg_Fini(); - PyAsyncGen_Fini(); + _PyAsyncGen_Fini(); _PyContext_Fini(); /* Cleanup Unicode implementation */