Skip to content

Commit 31a8393

Browse files
authored
Revert "bpo-32197: Try to fix a compiler error on OS X introduced in bpo-32030. (#4681)" (#4694)
* Revert "bpo-32197: Try to fix a compiler error on OS X introduced in bpo-32030. (#4681)" This reverts commit 13badcb. Re-apply commits: * "bpo-32030: _PyPathConfig_Init() sets home and program_name (#4673)" commit af5a895. * "bpo-32030: Fix config_get_program_name() on macOS (#4669)" commit e23c06e. * "bpo-32030: Add Python/pathconfig.c (#4668)" commit 0ea395a. * "bpo-32030: Don't call _PyPathConfig_Fini() in Py_FinalizeEx() (#4667)" commit ebac19d. * "bpo-32030: Fix Py_GetPath(): init program_name (#4665)" commit 9ac3d88. * Fix compilation error on macOS
1 parent 70d56fb commit 31a8393

File tree

12 files changed

+455
-424
lines changed

12 files changed

+455
-424
lines changed

Doc/c-api/init.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ The following functions can be safely called before Python is initialized:
4040
* :c:func:`Py_GetCompiler`
4141
* :c:func:`Py_GetCopyright`
4242
* :c:func:`Py_GetPlatform`
43-
* :c:func:`Py_GetProgramName`
4443
* :c:func:`Py_GetVersion`
4544

4645
* Utilities:
@@ -59,8 +58,8 @@ The following functions can be safely called before Python is initialized:
5958
The following functions **should not be called** before
6059
:c:func:`Py_Initialize`: :c:func:`Py_EncodeLocale`, :c:func:`Py_GetPath`,
6160
:c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`,
62-
:c:func:`Py_GetProgramFullPath`, :c:func:`Py_GetPythonHome` and
63-
:c:func:`PyEval_InitThreads`.
61+
:c:func:`Py_GetProgramFullPath`, :c:func:`Py_GetPythonHome`,
62+
:c:func:`Py_GetProgramName` and :c:func:`PyEval_InitThreads`.
6463

6564

6665
.. _global-conf-vars:

Include/internal/pystate.h

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,36 @@ typedef struct {
4848
#endif
4949
/* Set by Py_SetPath(), or computed by _PyPathConfig_Init() */
5050
wchar_t *module_search_path;
51+
/* Python program name */
52+
wchar_t *program_name;
53+
/* Set by Py_SetPythonHome() or PYTHONHOME environment variable */
54+
wchar_t *home;
5155
} _PyPathConfig;
5256

53-
#define _PyPathConfig_INIT {.module_search_path = NULL}
57+
#ifdef MS_WINDOWS
58+
#define _PyPathConfig_INIT \
59+
{.program_full_path = NULL, \
60+
.prefix = NULL, \
61+
.dll_path = NULL, \
62+
.module_search_path = NULL, \
63+
.program_name = NULL, \
64+
.home = NULL}
65+
#else
66+
#define _PyPathConfig_INIT \
67+
{.program_full_path = NULL, \
68+
.prefix = NULL, \
69+
.exec_prefix = NULL, \
70+
.module_search_path = NULL, \
71+
.program_name = NULL, \
72+
.home = NULL}
73+
#endif
74+
75+
PyAPI_DATA(_PyPathConfig) _Py_path_config;
76+
77+
PyAPI_FUNC(_PyInitError) _PyPathConfig_Calculate(
78+
_PyPathConfig *config,
79+
const _PyMainInterpreterConfig *main_config);
80+
PyAPI_FUNC(void) _PyPathConfig_Clear(_PyPathConfig *config);
5481

5582

5683
/* Full Python runtime state */

Include/pylifecycle.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,10 @@ PyAPI_FUNC(wchar_t *) Py_GetPath(void);
105105
#ifdef Py_BUILD_CORE
106106
PyAPI_FUNC(_PyInitError) _PyPathConfig_Init(
107107
const _PyMainInterpreterConfig *main_config);
108-
PyAPI_FUNC(void) _PyPathConfig_Fini(void);
109108
#endif
110109
PyAPI_FUNC(void) Py_SetPath(const wchar_t *);
111110
#ifdef MS_WINDOWS
112-
int _Py_CheckPython3();
111+
int _Py_CheckPython3(void);
113112
#endif
114113

115114
/* In their own files */

Include/pystate.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ typedef struct {
7272
(_PyMainInterpreterConfig){\
7373
.install_signal_handlers = -1, \
7474
.module_search_path_env = NULL, \
75-
.home = NULL}
75+
.home = NULL, \
76+
.program_name = NULL}
7677

7778
typedef struct _is {
7879

Makefile.pre.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,9 @@ PYTHON_OBJS= \
337337
Python/importdl.o \
338338
Python/marshal.o \
339339
Python/modsupport.o \
340-
Python/mystrtoul.o \
341340
Python/mysnprintf.o \
341+
Python/mystrtoul.o \
342+
Python/pathconfig.o \
342343
Python/peephole.o \
343344
Python/pyarena.o \
344345
Python/pyctype.o \

0 commit comments

Comments
 (0)