summaryrefslogtreecommitdiffstats
path: root/Python/pylifecycle.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-08-29 22:50:45 (GMT)
committerGitHub <noreply@github.com>2018-08-29 22:50:45 (GMT)
commitfbca90856d96273fd87c0b126f6e7966af7fbf7b (patch)
tree70be23311a03992573d5fb029acb03b208613440 /Python/pylifecycle.c
parentde427556746aa41a8b5198924ce423021bc0c718 (diff)
downloadcpython-fbca90856d96273fd87c0b126f6e7966af7fbf7b.zip
cpython-fbca90856d96273fd87c0b126f6e7966af7fbf7b.tar.gz
cpython-fbca90856d96273fd87c0b126f6e7966af7fbf7b.tar.bz2
bpo-34523: Use _PyCoreConfig instead of globals (GH-9005)
Use the core configuration of the interpreter, rather than using global configuration variables. For example, replace Py_QuietFlag with core_config->quiet.
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r--Python/pylifecycle.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index ad55b2c..7d17f2e 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -800,7 +800,7 @@ _Py_InitializeMainInterpreter(PyInterpreterState *interp,
return _Py_INIT_ERR("can't initialize time");
}
- if (_PySys_EndInit(interp->sysdict, &interp->config) < 0) {
+ if (_PySys_EndInit(interp->sysdict, interp) < 0) {
return _Py_INIT_ERR("can't finish initializing sys");
}
@@ -1285,7 +1285,7 @@ new_interpreter(PyThreadState **tstate_p)
goto handle_error;
Py_INCREF(interp->sysdict);
PyDict_SetItemString(interp->sysdict, "modules", modules);
- _PySys_EndInit(interp->sysdict, &interp->config);
+ _PySys_EndInit(interp->sysdict, interp);
}
bimod = _PyImport_FindBuiltin("builtins", modules);
@@ -1543,7 +1543,7 @@ is_valid_fd(int fd)
/* returns Py_None if the fd is not valid */
static PyObject*
-create_stdio(PyObject* io,
+create_stdio(const _PyCoreConfig *config, PyObject* io,
int fd, int write_mode, const char* name,
const char* encoding, const char* errors)
{
@@ -1556,6 +1556,7 @@ create_stdio(PyObject* io,
_Py_IDENTIFIER(isatty);
_Py_IDENTIFIER(TextIOWrapper);
_Py_IDENTIFIER(mode);
+ const int buffered_stdio = config->buffered_stdio;
if (!is_valid_fd(fd))
Py_RETURN_NONE;
@@ -1565,7 +1566,7 @@ create_stdio(PyObject* io,
depends on the presence of a read1() method which only exists on
buffered streams.
*/
- if (Py_UnbufferedStdioFlag && write_mode)
+ if (!buffered_stdio && write_mode)
buffering = 0;
else
buffering = -1;
@@ -1607,11 +1608,11 @@ create_stdio(PyObject* io,
Py_DECREF(res);
if (isatty == -1)
goto error;
- if (Py_UnbufferedStdioFlag)
+ if (!buffered_stdio)
write_through = Py_True;
else
write_through = Py_False;
- if (isatty && !Py_UnbufferedStdioFlag)
+ if (isatty && buffered_stdio)
line_buffering = Py_True;
else
line_buffering = Py_False;
@@ -1720,7 +1721,7 @@ init_sys_streams(PyInterpreterState *interp)
* and fileno() may point to an invalid file descriptor. For example
* GUI apps don't have valid standard streams by default.
*/
- std = create_stdio(iomod, fd, 0, "<stdin>",
+ std = create_stdio(config, iomod, fd, 0, "<stdin>",
config->stdio_encoding,
config->stdio_errors);
if (std == NULL)
@@ -1731,7 +1732,7 @@ init_sys_streams(PyInterpreterState *interp)
/* Set sys.stdout */
fd = fileno(stdout);
- std = create_stdio(iomod, fd, 1, "<stdout>",
+ std = create_stdio(config, iomod, fd, 1, "<stdout>",
config->stdio_encoding,
config->stdio_errors);
if (std == NULL)
@@ -1743,7 +1744,7 @@ init_sys_streams(PyInterpreterState *interp)
#if 1 /* Disable this if you have trouble debugging bootstrap stuff */
/* Set sys.stderr, replaces the preliminary stderr */
fd = fileno(stderr);
- std = create_stdio(iomod, fd, 1, "<stderr>",
+ std = create_stdio(config, iomod, fd, 1, "<stderr>",
config->stdio_encoding,
"backslashreplace");
if (std == NULL)