diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-11-23 16:03:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-23 16:03:20 (GMT) |
commit | 0327bde9da203bb256b58218d012ca76ad0db4e4 (patch) | |
tree | a54c0feb235156b9c01db641ebbf18f0a695ad56 /Include/pylifecycle.h | |
parent | bdb8315c21825487b54852ff0511fb4881ea2181 (diff) | |
download | cpython-0327bde9da203bb256b58218d012ca76ad0db4e4.zip cpython-0327bde9da203bb256b58218d012ca76ad0db4e4.tar.gz cpython-0327bde9da203bb256b58218d012ca76ad0db4e4.tar.bz2 |
bpo-32030: Rewrite calculate_path() (#4521)
* calculate_path() rewritten in Modules/getpath.c and PC/getpathp.c
* Move global variables into a new PyPathConfig structure.
* calculate_path():
* Split the huge calculate_path() function into subfunctions.
* Add PyCalculatePath structure to pass data between subfunctions.
* Document PyCalculatePath fields.
* Move cleanup code into a new calculate_free() subfunction
* calculate_init() now handles Py_DecodeLocale() failures properly
* calculate_path() is now atomic: only replace PyPathConfig
(path_config) at once on success.
* _Py_GetPythonHomeWithConfig() now returns an error on failure
* Add _Py_INIT_NO_MEMORY() helper: report a memory allocation failure
* Coding style fixes (PEP 7)
Diffstat (limited to 'Include/pylifecycle.h')
-rw-r--r-- | Include/pylifecycle.h | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/Include/pylifecycle.h b/Include/pylifecycle.h index 3b603c8..efdc58e 100644 --- a/Include/pylifecycle.h +++ b/Include/pylifecycle.h @@ -7,23 +7,7 @@ extern "C" { #endif -PyAPI_FUNC(void) Py_SetProgramName(wchar_t *); -PyAPI_FUNC(wchar_t *) Py_GetProgramName(void); - -PyAPI_FUNC(void) Py_SetPythonHome(wchar_t *); -PyAPI_FUNC(wchar_t *) Py_GetPythonHome(void); -#ifdef Py_BUILD_CORE -PyAPI_FUNC(wchar_t *) _Py_GetPythonHomeWithConfig( - const _PyMainInterpreterConfig *config); -#endif - #ifndef Py_LIMITED_API -/* Only used by applications that embed the interpreter and need to - * override the standard encoding determination mechanism - */ -PyAPI_FUNC(int) Py_SetStandardStreamEncoding(const char *encoding, - const char *errors); - typedef struct { const char *prefix; const char *msg; @@ -46,9 +30,31 @@ typedef struct { Don't abort() the process on such error. */ #define _Py_INIT_USER_ERR(MSG) \ (_PyInitError){.prefix = _Py_INIT_GET_FUNC(), .msg = (MSG), .user_err = 1} +#define _Py_INIT_NO_MEMORY() _Py_INIT_ERR("memory allocation failed") #define _Py_INIT_FAILED(err) \ (err.msg != NULL) +#endif + + +PyAPI_FUNC(void) Py_SetProgramName(wchar_t *); +PyAPI_FUNC(wchar_t *) Py_GetProgramName(void); + +PyAPI_FUNC(void) Py_SetPythonHome(wchar_t *); +PyAPI_FUNC(wchar_t *) Py_GetPythonHome(void); +#ifdef Py_BUILD_CORE +PyAPI_FUNC(_PyInitError) _Py_GetPythonHomeWithConfig( + const _PyMainInterpreterConfig *config, + wchar_t **home); +#endif + +#ifndef Py_LIMITED_API +/* Only used by applications that embed the interpreter and need to + * override the standard encoding determination mechanism + */ +PyAPI_FUNC(int) Py_SetStandardStreamEncoding(const char *encoding, + const char *errors); + /* PEP 432 Multi-phase initialization API (Private while provisional!) */ PyAPI_FUNC(_PyInitError) _Py_InitializeCore(const _PyCoreConfig *); PyAPI_FUNC(int) _Py_IsCoreInitialized(void); |