summaryrefslogtreecommitdiffstats
path: root/Python/getversion.c
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2022-11-15 16:45:11 (GMT)
committerGitHub <noreply@github.com>2022-11-15 16:45:11 (GMT)
commit3c57971a2d3b6d2c6fd1f525ba2108fccb35add2 (patch)
tree697c28707c62e43c9a444af3069304b8fad2e54b /Python/getversion.c
parent73943cbc4c5e97f71b76150c549d07e8ed00066b (diff)
downloadcpython-3c57971a2d3b6d2c6fd1f525ba2108fccb35add2.zip
cpython-3c57971a2d3b6d2c6fd1f525ba2108fccb35add2.tar.gz
cpython-3c57971a2d3b6d2c6fd1f525ba2108fccb35add2.tar.bz2
gh-81057: Move Globals in Core Code to _PyRuntimeState (gh-99496)
This is the first of several changes to consolidate non-object globals in core code. https://github.com/python/cpython/issues/81057
Diffstat (limited to 'Python/getversion.c')
-rw-r--r--Python/getversion.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/Python/getversion.c b/Python/getversion.c
index 4691045..5db836a 100644
--- a/Python/getversion.c
+++ b/Python/getversion.c
@@ -5,12 +5,23 @@
#include "patchlevel.h"
-const char *
-Py_GetVersion(void)
+static int initialized = 0;
+static char version[250];
+
+void _Py_InitVersion(void)
{
- static char version[250];
+ if (initialized) {
+ return;
+ }
+ initialized = 1;
PyOS_snprintf(version, sizeof(version), "%.80s (%.80s) %.80s",
PY_VERSION, Py_GetBuildInfo(), Py_GetCompiler());
+}
+
+const char *
+Py_GetVersion(void)
+{
+ _Py_InitVersion();
return version;
}