]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport trunk's r43510: In the fdopen(fd, 'a') case on UNIX, don't try to
authorThomas Wouters <thomas@python.org>
Fri, 31 Mar 2006 22:39:56 +0000 (22:39 +0000)
committerThomas Wouters <thomas@python.org>
Fri, 31 Mar 2006 22:39:56 +0000 (22:39 +0000)
set fd's flags to -1 if fcntl() and fdopen() both fail.

Modules/posixmodule.c

index f7032070c50bae2cc464ae29b6d265324d41da9e..e92f69e79fe3ea4eb77ebd68b8f70bdb3eb4cdea 100644 (file)
@@ -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 {