10000 gh-106078: Suppress the warning caused by multi-phase initialization of `decimal` by CharlieZhao95 · Pull Request #107524 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

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

Merged
merged 6 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Move minalloc_is_set outside
  • Loading branch information
CharlieZhao95 committed Aug 1, 2023
commit ed8a2b3a1714cc7ee407c10b7eed2fb2f0814b2b
13 changes: 7 additions & 6 deletions Modules/_decimal/_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -5876,12 +5876,7 @@ cfunc_noargs(PyTypeObject *t, const char *name)
return NULL;
}


/* Suppress the warning caused by multi-phase initialization */
__attribute__((constructor)) void minalloc_init(void)
{
mpd_setminalloc(_Py_DEC_MINALLOC);
}
static int minalloc_is_set = 0;

static int
_decimal_exec(PyObject *m)
Expand All @@ -5905,6 +5900,12 @@ _decimal_exec(PyObject *m)
mpd_callocfunc = mpd_callocfunc_em;
mpd_free = PyMem_Free;

/* 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);

/* Init external C-API functions */
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
0