From: Thomas Wouters Date: Fri, 31 Mar 2006 22:39:56 +0000 (+0000) Subject: Backport trunk's r43510: In the fdopen(fd, 'a') case on UNIX, don't try to X-Git-Tag: v2.4.4c1~307 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe1c16f4bee33293456f563808529b79c1bdca2a;p=thirdparty%2FPython%2Fcpython.git 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. --- diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index f7032070c50b..e92f69e79fe3 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -5467,7 +5467,7 @@ posix_fdopen(PyObject *self, PyObject *args) if (flags != -1) fcntl(fd, F_SETFL, flags | O_APPEND); fp = fdopen(fd, mode); - if (fp == NULL) + if (fp == NULL && flags != -1) /* restore old mode if fdopen failed */ fcntl(fd, F_SETFL, flags); } else {