diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-12-21 15:49:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-21 15:49:13 (GMT) |
commit | 9bee329130aae5a13050c08dab9d349b76e66835 (patch) | |
tree | 828e5eba0807b15d60bb7f5162685d0dc993fc42 /Include | |
parent | 9dd762013fd9fcf975ad51700b55d050ca9ed60e (diff) | |
download | cpython-9bee329130aae5a13050c08dab9d349b76e66835.zip cpython-9bee329130aae5a13050c08dab9d349b76e66835.tar.gz cpython-9bee329130aae5a13050c08dab9d349b76e66835.tar.bz2 |
bpo-32030: Add _Py_FindEnvConfigValue() (#4963)
Add a new _Py_FindEnvConfigValue() function: code shared between
Windows and Unix implementations of _PyPathConfig_Calculate() to read
the pyenv.cfg file.
_Py_FindEnvConfigValue() now uses _Py_DecodeUTF8_surrogateescape()
instead of using a Python Unicode string, the Python API must not be
used early during Python initialization. Same change in Unix
search_for_exec_prefix(): use _Py_DecodeUTF8_surrogateescape().
Cleanup also encode_current_locale(): PyMem_RawFree/PyMem_Free can be
called with NULL.
Fix also "NUL byte" => "NULL byte" typo.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/fileutils.h | 7 | ||||
-rw-r--r-- | Include/pylifecycle.h | 5 |
2 files changed, 12 insertions, 0 deletions
diff --git a/Include/fileutils.h b/Include/fileutils.h index b7b6cd2..d027e18 100644 --- a/Include/fileutils.h +++ b/Include/fileutils.h @@ -19,6 +19,13 @@ PyAPI_FUNC(char*) _Py_EncodeLocaleRaw( size_t *error_pos); #endif +#ifdef Py_BUILD_CORE +PyAPI_FUNC(wchar_t*) _Py_DecodeUTF8_surrogateescape( + const char *s, + Py_ssize_t size, + size_t *p_wlen); +#endif + #ifndef Py_LIMITED_API PyAPI_FUNC(PyObject *) _Py_device_encoding(int); diff --git a/Include/pylifecycle.h b/Include/pylifecycle.h index da740fe..659c6df 100644 --- a/Include/pylifecycle.h +++ b/Include/pylifecycle.h @@ -118,6 +118,11 @@ PyAPI_FUNC(wchar_t *) Py_GetPath(void); #ifdef Py_BUILD_CORE PyAPI_FUNC(_PyInitError) _PyPathConfig_Init(const _PyCoreConfig *core_config); PyAPI_FUNC(PyObject*) _PyPathConfig_ComputeArgv0(int argc, wchar_t **argv); +PyAPI_FUNC(int) _Py_FindEnvConfigValue( + FILE *env_file, + const wchar_t *key, + wchar_t *value, + size_t value_size); #endif PyAPI_FUNC(void) Py_SetPath(const wchar_t *); #ifdef MS_WINDOWS |