| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b0e1ae5 commit 1ce152a
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -472,8 +472,8 @@ Process-wide parameters | |||
| 472 | 472 | dependent delimiter character, which is ``':'`` on Unix and Mac OS X, ``';'`` | |
| 473 | 473 | on Windows. | |
| 474 | 474 | ||
| 475 | - This also causes :data:`sys.executable` to be set only to the raw program | ||
| 476 | - name (see :c:func:`Py_SetProgramName`) and for :data:`sys.prefix` and | ||
| 475 | + This also causes :data:`sys.executable` to be set to the program | ||
| 476 | + full path (see :c:func:`Py_GetProgramFullPath`) and for :data:`sys.prefix` and | ||
| 477 | 477 | :data:`sys.exec_prefix` to be empty. It is up to the caller to modify these | |
| 478 | 478 | if required after calling :c:func:`Py_Initialize`. | |
| 479 | 479 | ||
@@ -483,6 +483,10 @@ Process-wide parameters | |||
| 483 | 483 | The path argument is copied internally, so the caller may free it after the | |
| 484 | 484 | call completes. | |
| 485 | 485 | ||
| 486 | + .. versionchanged:: 3.8 | ||
| 487 | + The program full path is now used for :data:`sys.executable`, instead | ||
| 488 | + of the program name. | ||
| 489 | + | ||
| 486 | 490 | ||
| 487 | 491 | .. c:function:: const char* Py_GetVersion() | |
| 488 | 492 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1347,6 +1347,11 @@ Build and C API Changes | |||
| 1347 | 1347 | parameter for indicating the number of positional-only arguments. | |
| 1348 | 1348 | (Contributed by Pablo Galindo in :issue:`37221`.) | |
| 1349 | 1349 | ||
| 1350 | + * :c:func:`Py_SetPath` now sets :data:`sys.executable` to the program full | ||
| 1351 | + path (:c:func:`Py_GetProgramFullPath`) rather than to the program name | ||
| 1352 | + (:c:func:`Py_GetProgramName`). | ||
| 1353 | + (Contributed by Victor Stinner in :issue:`38234`.) | ||
| 1354 | + | ||
| 1350 | 1355 | ||
| 1351 | 1356 | Deprecated | |
| 1352 | 1357 | ========== | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + :c:func:`Py_SetPath` now sets :data:`sys.executable` to the program full | ||
| 2 | + path (:c:func:`Py_GetProgramFullPath`) rather than to the program name | ||
| 3 | + (:c:func:`Py_GetProgramName`). | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,6 +23,7 @@ wchar_t *_Py_dll_path = NULL; | |||
| 23 | 23 | static int | |
| 24 | 24 | copy_wstr(wchar_t **dst, const wchar_t *src) | |
| 25 | 25 | { | |
| 26 | + assert(*dst == NULL); | ||
| 26 | 27 | if (src != NULL) { | |
| 27 | 28 | *dst = _PyMem_RawWcsdup(src); | |
| 28 | 29 | if (*dst == NULL) { | |
@@ -172,6 +173,7 @@ pathconfig_set_from_config(_PyPathConfig *pathconfig, const PyConfig *config) | |||
| 172 | 173 | _PyMem_SetDefaultAllocator(PYMEM_DOMAIN_RAW, &old_alloc); | |
| 173 | 174 | ||
| 174 | 175 | if (config->module_search_paths_set) { | |
| 176 | + PyMem_RawFree(pathconfig->module_search_path); | ||
| 175 | 177 | pathconfig->module_search_path = _PyWideStringList_Join(&config->module_search_paths, DELIM); | |
| 176 | 178 | if (pathconfig->module_search_path == NULL) { | |
| 177 | 179 | goto no_memory; | |
@@ -180,6 +182,8 @@ pathconfig_set_from_config(_PyPathConfig *pathconfig, const PyConfig *config) | |||
| 180 | 182 | ||
| 181 | 183 | #define COPY_CONFIG(PATH_ATTR, CONFIG_ATTR) \ | |
| 182 | 184 | if (config->CONFIG_ATTR) { \ | |
| 185 | + PyMem_RawFree(pathconfig->PATH_ATTR); \ | ||
| 186 | + pathconfig->PATH_ATTR = NULL; \ | ||
| 183 | 187 | if (copy_wstr(&pathconfig->PATH_ATTR, config->CONFIG_ATTR) < 0) { \ | |
| 184 | 188 | goto no_memory; \ | |
| 185 | 189 | } \ | |
@@ -455,16 +459,15 @@ Py_SetPath(const wchar_t *path) | |||
| 455 | 459 | PyMemAllocatorEx old_alloc; | |
| 456 | 460 | _PyMem_SetDefaultAllocator(PYMEM_DOMAIN_RAW, &old_alloc); | |
| 457 | 461 | ||
| 458 | - /* Getting the program name calls pathconfig_global_init() */ | ||
| 459 | - wchar_t *program_name = _PyMem_RawWcsdup(Py_GetProgramName()); | ||
| 462 | + /* Getting the program full path calls pathconfig_global_init() */ | ||
| 463 | + wchar_t *program_full_path = _PyMem_RawWcsdup(Py_GetProgramFullPath()); | ||
| 460 | 464 | ||
| 461 | 465 | PyMem_RawFree(_Py_path_config.program_full_path); | |
| 462 | 466 | PyMem_RawFree(_Py_path_config.prefix); | |
| 463 | 467 | PyMem_RawFree(_Py_path_config.exec_prefix); | |
| 464 | 468 | PyMem_RawFree(_Py_path_config.module_search_path); | |
| 465 | 469 | ||
| 466 | - /* Copy program_name to program_full_path */ | ||
| 467 | - _Py_path_config.program_full_path = program_name; | ||
| 470 | + _Py_path_config.program_full_path = program_full_path; | ||
| 468 | 471 | _Py_path_config.prefix = _PyMem_RawWcsdup(L""); | |
| 469 | 472 | _Py_path_config.exec_prefix = _PyMem_RawWcsdup(L""); | |
| 470 | 473 | _Py_path_config.module_search_path = _PyMem_RawWcsdup(path); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments