Skip to content

Commit fe1c16f

Browse files
committed
Backport trunk's r43510: In the fdopen(fd, 'a') case on UNIX, don't try to
set fd's flags to -1 if fcntl() and fdopen() both fail.
1 parent 40fec61 commit fe1c16f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Modules/posixmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5467,7 +5467,7 @@ posix_fdopen(PyObject *self, PyObject *args)
54675467
if (flags != -1)
54685468
fcntl(fd, F_SETFL, flags | O_APPEND);
54695469
fp = fdopen(fd, mode);
5470-
if (fp == NULL)
5470+
if (fp == NULL && flags != -1)
54715471
/* restore old mode if fdopen failed */
54725472
fcntl(fd, F_SETFL, flags);
54735473
} else {

0 commit comments

Comments
 (0)