mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
bpo-45434: Convert Py_GETENV() macro to a function (GH-28912)
Avoid calling directly getenv() in the header file.
This commit is contained in:
parent
9c4766772c
commit
489176e428
2 changed files with 9 additions and 1 deletions
|
@ -29,7 +29,7 @@ PyAPI_DATA(int) Py_LegacyWindowsStdioFlag;
|
||||||
/* this is a wrapper around getenv() that pays attention to
|
/* this is a wrapper around getenv() that pays attention to
|
||||||
Py_IgnoreEnvironmentFlag. It should be used for getting variables like
|
Py_IgnoreEnvironmentFlag. It should be used for getting variables like
|
||||||
PYTHONPATH and PYTHONHOME from the environment */
|
PYTHONPATH and PYTHONHOME from the environment */
|
||||||
#define Py_GETENV(s) (Py_IgnoreEnvironmentFlag ? NULL : getenv(s))
|
PyAPI_DATA(char*) Py_GETENV(const char *name);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,6 +249,14 @@ fail:
|
||||||
#undef SET_ITEM_STR
|
#undef SET_ITEM_STR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char*
|
||||||
|
Py_GETENV(const char *name)
|
||||||
|
{
|
||||||
|
if (Py_IgnoreEnvironmentFlag) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return getenv(name);
|
||||||
|
}
|
||||||
|
|
||||||
/* --- PyStatus ----------------------------------------------- */
|
/* --- PyStatus ----------------------------------------------- */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue