mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
bpo-32030: Add _PyMainInterpreterConfig_ReadEnv() (#4542)
Py_GetPath() and Py_Main() now call _PyMainInterpreterConfig_ReadEnv() to share the same code to get environment variables. Changes: * Add _PyMainInterpreterConfig_ReadEnv() * Add _PyMainInterpreterConfig_Clear() * Add _PyMem_RawWcsdup() * _PyMainInterpreterConfig: rename pythonhome to home * Rename _Py_ReadMainInterpreterConfig() to _PyMainInterpreterConfig_Read() * Use _Py_INIT_USER_ERR(), instead of _Py_INIT_ERR(), for decoding errors: the user is able to fix the issue, it's not a bug in Python. Same change was made in _Py_INIT_NO_MEMORY(). * Remove _Py_GetPythonHomeWithConfig()
This commit is contained in:
parent
84c4b1938f
commit
46972b7bc3
8 changed files with 165 additions and 142 deletions
|
|
@ -455,6 +455,24 @@ PyMem_Free(void *ptr)
|
|||
}
|
||||
|
||||
|
||||
wchar_t*
|
||||
_PyMem_RawWcsdup(const wchar_t *str)
|
||||
{
|
||||
size_t len = wcslen(str);
|
||||
if (len > (size_t)PY_SSIZE_T_MAX / sizeof(wchar_t) - 1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t size = (len + 1) * sizeof(wchar_t);
|
||||
wchar_t *str2 = PyMem_RawMalloc(size);
|
||||
if (str2 == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(str2, str, size);
|
||||
return str2;
|
||||
}
|
||||
|
||||
char *
|
||||
_PyMem_RawStrdup(const char *str)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue