]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106078: Suppress the warning caused by multi-phase initialization of `decimal...
authorCharlie Zhao <zhaoyu_hit@qq.com>
Fri, 6 Oct 2023 23:15:19 +0000 (07:15 +0800)
committerGitHub <noreply@github.com>
Fri, 6 Oct 2023 23:15:19 +0000 (00:15 +0100)
Modules/_decimal/_decimal.c
Tools/c-analyzer/cpython/ignored.tsv

index b49ea3cbb410efa94c22034e15ea36b201047a44..99ff9aa17b179ccddfc7f5c79cf60e9e89f14279 100644 (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);
 
index f9911643332b5e474d17eafb3a369fccde8bf71a..ca656f0760ab4fca41199e90c584d52ae109dae7 100644 (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