diff -r 7c98768368cb Python/fileutils.c --- a/Python/fileutils.c Sat Nov 19 01:06:37 2016 +0000 +++ b/Python/fileutils.c Sat Nov 19 15:22:57 2016 +0100 @@ -886,7 +886,7 @@ return 0; } - res = fcntl(fd, F_SETFD, flags); + res = fcntl(fd, F_SETFD, new_flags); if (res < 0) { if (raise) PyErr_SetFromErrno(PyExc_OSError);