gh-106078: Suppress the warning caused by multi-phase initialization of decimal (#107524)

This commit is contained in:
Charlie Zhao 2023-10-07 07:15:19 +08:00 committed by GitHub
parent 5fd8821cf8
commit de1052245f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -5877,6 +5877,7 @@ error:
return NULL;
}
static int minalloc_is_set = 0;
static int
_decimal_exec(PyObject *m)
@ -5899,7 +5900,12 @@ _decimal_exec(PyObject *m)
mpd_reallocfunc = PyMem_Realloc;
mpd_callocfunc = mpd_callocfunc_em;
mpd_free = PyMem_Free;
mpd_setminalloc(_Py_DEC_MINALLOC);
/* Suppress the warning caused by multi-phase initialization */
if (!minalloc_is_set) {
mpd_setminalloc(_Py_DEC_MINALLOC);
minalloc_is_set = 1;
}
decimal_state *state = get_module_state(m);

View File

@ -166,6 +166,9 @@ Python/pylifecycle.c fatal_error reentrant -
# explicitly protected, internal-only
Modules/_xxinterpchannelsmodule.c - _globals -
# set once during module init
Modules/_decimal/_decimal.c - minalloc_is_set -
##################################
## not significant

Can't render this file because it has a wrong number of fields in line 4.