-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
Open
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir
Description
Documentation
Follow up on: #128377
According to docs, PYTHONUNBUFFERED
is true if set as a non-empty string. Setting it to "0"
(which is non-empty string) has effect of disabling it though.
Related C code:
Lines 1786 to 1790 in d903b17
int unbuffered_stdio = 0; | |
_Py_get_env_flag(use_env, &unbuffered_stdio, "PYTHONUNBUFFERED"); | |
if (unbuffered_stdio) { | |
config->buffered_stdio = 0; | |
} |
Lines 563 to 578 in d903b17
void | |
_Py_get_env_flag(int use_environment, int *flag, const char *name) | |
{ | |
const char *var = _Py_GetEnv(use_environment, name); | |
if (!var) { | |
return; | |
} | |
int value; | |
if (_Py_str_to_int(var, &value) < 0 || value < 0) { | |
/* PYTHONDEBUG=text and PYTHONDEBUG=-2 behave as PYTHONDEBUG=1 */ | |
value = 1; | |
} | |
if (*flag < value) { | |
*flag = value; | |
} | |
} |
Lines 545 to 560 in d903b17
int | |
_Py_str_to_int(const char *str, int *result) | |
{ | |
const char *endptr = str; | |
errno = 0; | |
long value = strtol(str, (char **)&endptr, 10); | |
if (*endptr != '\0' || errno == ERANGE) { | |
return -1; | |
} | |
if (value < INT_MIN || value > INT_MAX) { | |
return -1; | |
} | |
*result = (int)value; | |
return 0; | |
} |
We should probably rephrase it from:
If this is set to a non-empty string...
to:
If this is set...
Linked PRs
Metadata
Metadata
Assignees
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir
Projects
Status
Todo