Skip to content

Commit 6628e85

Browse files
_Py_IS_FINALIZING() -> _Py_IsFinalizing().
1 parent 69fe645 commit 6628e85

File tree

8 files changed

+19
-10
lines changed

8 files changed

+19
-10
lines changed

Include/internal/pystate.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ PyAPI_DATA(_PyRuntimeState) _PyRuntime;
8585
PyAPI_FUNC(void) _PyRuntimeState_Init(_PyRuntimeState *);
8686
PyAPI_FUNC(void) _PyRuntimeState_Fini(_PyRuntimeState *);
8787

88+
#define _Py_CURRENTLY_FINALIZING(tstate) \
89+
(_PyRuntime.finalizing == tstate)
90+
91+
92+
/* Other */
93+
8894
PyAPI_FUNC(void) _PyInterpreterState_Enable(_PyRuntimeState *);
8995

9096
#ifdef __cplusplus

Include/pylifecycle.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,7 @@ PyAPI_FUNC(void) _PyType_Fini(void);
119119
PyAPI_FUNC(void) _Py_HashRandomization_Fini(void);
120120
PyAPI_FUNC(void) PyAsyncGen_Fini(void);
121121

122-
#define _Py_IS_FINALIZING() \
123-
(_PyRuntime.finalizing != NULL)
124-
#define _Py_CURRENTLY_FINALIZING(tstate) \
125-
(_PyRuntime.finalizing == tstate)
122+
PyAPI_FUNC(int) _Py_IsFinalizing(void);
126123
#endif
127124

128125
/* Signals */

Modules/_io/bufferedio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ _enter_buffered_busy(buffered *self)
276276
"reentrant call inside %R", self);
277277
return 0;
278278
}
279-
relax_locking = _Py_IS_FINALIZING();
279+
relax_locking = _Py_IsFinalizing();
280280
Py_BEGIN_ALLOW_THREADS
281281
if (!relax_locking)
282282
st = PyThread_acquire_lock(self->lock, 1);

Modules/_winapi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ overlapped_dealloc(OverlappedObject *self)
114114
{
115115
/* The operation is no longer pending -- nothing to do. */
116116
}
117-
else if _Py_IS_FINALIZING()
117+
else if _Py_IsFinalizing()
118118
{
119119
/* The operation is still pending -- give a warning. This
120120
will probably only happen on Windows XP. */

Python/_warnings.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ get_warnings_attr(const char *attr, int try_import)
4747
}
4848

4949
/* don't try to import after the start of the Python finallization */
50-
if (try_import && !_Py_IS_FINALIZING()) {
50+
if (try_import && !_Py_IsFinalizing()) {
5151
warnings_module = PyImport_Import(warnings_str);
5252
if (warnings_module == NULL) {
5353
/* Fallback to the C implementation if we cannot get

Python/ceval.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ PyEval_RestoreThread(PyThreadState *tstate)
271271
int err = errno;
272272
take_gil(tstate);
273273
/* _Py_Finalizing is protected by the GIL */
274-
if (_Py_IS_FINALIZING() && !_Py_CURRENTLY_FINALIZING(tstate)) {
274+
if (_Py_IsFinalizing() && !_Py_CURRENTLY_FINALIZING(tstate)) {
275275
drop_gil(tstate);
276276
PyThread_exit_thread();
277277
assert(0); /* unreachable */
@@ -986,7 +986,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
986986
take_gil(tstate);
987987

988988
/* Check if we should make a quick exit. */
989-
if (_Py_IS_FINALIZING() &&
989+
if (_Py_IsFinalizing() &&
990990
!_Py_CURRENTLY_FINALIZING(tstate))
991991
{
992992
drop_gil(tstate);

Python/pylifecycle.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ _PyRuntime_Finalize(void)
100100
_PyRuntimeState_Fini(&_PyRuntime);
101101
}
102102

103+
int
104+
_Py_IsFinalizing(void)
105+
{
106+
return _PyRuntime.finalizing != NULL;
107+
}
108+
103109
/* Global configuration variable declarations are in pydebug.h */
104110
/* XXX (ncoghlan): move those declarations to pylifecycle.h? */
105111
int Py_DebugFlag; /* Needed by parser.c */

Python/sysmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,7 @@ Clear the internal type lookup cache.");
13371337
static PyObject *
13381338
sys_is_finalizing(PyObject* self, PyObject* args)
13391339
{
1340-
return PyBool_FromLong(_Py_IS_FINALIZING());
1340+
return PyBool_FromLong(_Py_IsFinalizing());
13411341
}
13421342

13431343
PyDoc_STRVAR(is_finalizing_doc,

0 commit comments

Comments
 (0)