mirror of
https://github.com/python/cpython.git
synced 2025-10-21 14:12:27 +00:00
gh-77782: Deprecate global configuration variable (#93943)
Deprecate global configuration variable like Py_IgnoreEnvironmentFlag: the Py_InitializeFromConfig() API should be instead. Fix declaration of Py_GETENV(): use PyAPI_FUNC(), not PyAPI_DATA().
This commit is contained in:
parent
f64557f480
commit
0ff626f210
8 changed files with 96 additions and 28 deletions
|
@ -201,6 +201,8 @@ int Py_LegacyWindowsStdioFlag = 0; /* Uses FileIO instead of WindowsConsoleIO */
|
|||
static PyObject *
|
||||
_Py_GetGlobalVariablesAsDict(void)
|
||||
{
|
||||
_Py_COMP_DIAG_PUSH
|
||||
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
|
||||
PyObject *dict, *obj;
|
||||
|
||||
dict = PyDict_New();
|
||||
|
@ -267,15 +269,19 @@ fail:
|
|||
#undef SET_ITEM
|
||||
#undef SET_ITEM_INT
|
||||
#undef SET_ITEM_STR
|
||||
_Py_COMP_DIAG_POP
|
||||
}
|
||||
|
||||
char*
|
||||
Py_GETENV(const char *name)
|
||||
{
|
||||
_Py_COMP_DIAG_PUSH
|
||||
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
|
||||
if (Py_IgnoreEnvironmentFlag) {
|
||||
return NULL;
|
||||
}
|
||||
return getenv(name);
|
||||
_Py_COMP_DIAG_POP
|
||||
}
|
||||
|
||||
/* --- PyStatus ----------------------------------------------- */
|
||||
|
@ -1443,6 +1449,8 @@ config_get_env_dup(PyConfig *config,
|
|||
static void
|
||||
config_get_global_vars(PyConfig *config)
|
||||
{
|
||||
_Py_COMP_DIAG_PUSH
|
||||
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
|
||||
if (config->_config_init != _PyConfig_INIT_COMPAT) {
|
||||
/* Python and Isolated configuration ignore global variables */
|
||||
return;
|
||||
|
@ -1478,6 +1486,7 @@ config_get_global_vars(PyConfig *config)
|
|||
|
||||
#undef COPY_FLAG
|
||||
#undef COPY_NOT_FLAG
|
||||
_Py_COMP_DIAG_POP
|
||||
}
|
||||
|
||||
|
||||
|
@ -1485,6 +1494,8 @@ config_get_global_vars(PyConfig *config)
|
|||
static void
|
||||
config_set_global_vars(const PyConfig *config)
|
||||
{
|
||||
_Py_COMP_DIAG_PUSH
|
||||
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
|
||||
#define COPY_FLAG(ATTR, VAR) \
|
||||
if (config->ATTR != -1) { \
|
||||
VAR = config->ATTR; \
|
||||
|
@ -1519,6 +1530,7 @@ config_set_global_vars(const PyConfig *config)
|
|||
|
||||
#undef COPY_FLAG
|
||||
#undef COPY_NOT_FLAG
|
||||
_Py_COMP_DIAG_POP
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue