diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-12-01 19:50:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-01 19:50:58 (GMT) |
commit | 0ea395ae964c9cd0f499e2ef0d0030c971201220 (patch) | |
tree | 92e86e1b1754d179c8dc4b397f4fa33e020a3aee /Python/pylifecycle.c | |
parent | ebac19dad6263141d5db0a2c923efe049dba99d2 (diff) | |
download | cpython-0ea395ae964c9cd0f499e2ef0d0030c971201220.zip cpython-0ea395ae964c9cd0f499e2ef0d0030c971201220.tar.gz cpython-0ea395ae964c9cd0f499e2ef0d0030c971201220.tar.bz2 |
bpo-32030: Add Python/pathconfig.c (#4668)
* Factorize code from PC/getpathp.c and Modules/getpath.c to remove
duplicated code
* rename pathconfig_clear() to _PyPathConfig_Clear()
* Inline _PyPathConfig_Fini() in pymain_impl() and then remove it,
since it's a oneliner
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r-- | Python/pylifecycle.c | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index a1b29f2..8d71154 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -1489,61 +1489,6 @@ Py_EndInterpreter(PyThreadState *tstate) PyInterpreterState_Delete(interp); } -#ifdef MS_WINDOWS -static wchar_t *progname = L"python"; -#else -static wchar_t *progname = L"python3"; -#endif - -void -Py_SetProgramName(wchar_t *pn) -{ - if (pn && *pn) - progname = pn; -} - -wchar_t * -Py_GetProgramName(void) -{ - return progname; -} - -static wchar_t *default_home = NULL; - -void -Py_SetPythonHome(wchar_t *home) -{ - default_home = home; -} - - -wchar_t* -Py_GetPythonHome(void) -{ - /* Use a static buffer to avoid heap memory allocation failure. - Py_GetPythonHome() doesn't allow to report error, and the caller - doesn't release memory. */ - static wchar_t buffer[MAXPATHLEN+1]; - - if (default_home) { - return default_home; - } - - char *home = Py_GETENV("PYTHONHOME"); - if (!home) { - return NULL; - } - - size_t size = Py_ARRAY_LENGTH(buffer); - size_t r = mbstowcs(buffer, home, size); - if (r == (size_t)-1 || r >= size) { - /* conversion failed or the static buffer is too small */ - return NULL; - } - - return buffer; -} - /* Add the __main__ module */ static _PyInitError |