summaryrefslogtreecommitdiffstats
path: root/Modules/_io
diff options
context:
space:
mode:
authorDavid Herberth <github@dav1d.de>2018-10-19 22:32:04 (GMT)
committerVictor Stinner <vstinner@redhat.com>2018-10-19 22:32:04 (GMT)
commit8deab9672554edaf58f91e238cc899463d53f6ea (patch)
tree0f3ad581a9889fdcd5b05f948a55008f559799b5 /Modules/_io
parentacef69068f61c9f4141f8509b6a1bfaadab87b5c (diff)
downloadcpython-8deab9672554edaf58f91e238cc899463d53f6ea.zip
cpython-8deab9672554edaf58f91e238cc899463d53f6ea.tar.gz
cpython-8deab9672554edaf58f91e238cc899463d53f6ea.tar.bz2
bpo-34070: open() only checks for isatty if buffering < 0 (GH-8187)
Diffstat (limited to 'Modules/_io')
-rw-r--r--Modules/_io/_iomodule.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c
index 0d8a638..eedca01 100644
--- a/Modules/_io/_iomodule.c
+++ b/Modules/_io/_iomodule.c
@@ -241,7 +241,7 @@ _io_open_impl(PyObject *module, PyObject *file, const char *mode,
char rawmode[6], *m;
int line_buffering, is_number;
- long isatty;
+ long isatty = 0;
PyObject *raw, *modeobj = NULL, *buffer, *wrapper, *result = NULL, *path_or_fd = NULL;
@@ -388,7 +388,7 @@ _io_open_impl(PyObject *module, PyObject *file, const char *mode,
goto error;
/* buffering */
- {
+ if (buffering < 0) {
PyObject *res = _PyObject_CallMethodId(raw, &PyId_isatty, NULL);
if (res == NULL)
goto error;
@@ -398,7 +398,7 @@ _io_open_impl(PyObject *module, PyObject *file, const char *mode,
goto error;
}
- if (buffering == 1 || (buffering < 0 && isatty)) {
+ if (buffering == 1 || isatty) {
buffering = -1;
line_buffering = 1;
}