From: Thomas Wouters Date: Fri, 31 Mar 2006 22:38:19 +0000 (+0000) Subject: In the fdopen(fd, 'a') case on UNIX, don't try to set fd's flags to -1 if X-Git-Tag: v2.5a1~107 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2a9a6b0e86320ba0793051f3050034ae4290c764;p=thirdparty%2FPython%2Fcpython.git In the fdopen(fd, 'a') case on UNIX, don't try to set fd's flags to -1 if fcntl() and fdopen() both fail. Will backport. --- diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index a27a2af10064..50ee0e33925e 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -5777,7 +5777,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 {