Skip to content

Commit

Permalink
pythongh-106078: Suppress the warning caused by multi-phase initializ…
Browse files Browse the repository at this point in the history
…ation of `decimal` (python#107524)
  • Loading branch information
CharlieZhao95 authored and Glyphack committed Jan 27, 2024
1 parent 5bfee3d commit 56a89cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Modules/_decimal/_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -5877,6 +5877,7 @@ cfunc_noargs(PyTypeObject *t, const char *name)
return NULL;
}

static int minalloc_is_set = 0;

static int
_decimal_exec(PyObject *m)
Expand All @@ -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);

Expand Down
3 changes: 3 additions & 0 deletions Tools/c-analyzer/cpython/ignored.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 56a89cb

Please sign in to comment.