Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 6 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Modules/_decimal/_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -5876,6 +5876,7 @@ cfunc_noargs(PyTypeObject *t, const char *name)
return NULL;
}

static int minalloc_is_set = 0;

static int
_decimal_exec(PyObject *m)
Expand All @@ -5898,7 +5899,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) {
Eclips4 marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -159,6 +159,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
Loading