]> granicus.if.org Git - python/commitdiff
In the fdopen(fd, 'a') case on UNIX, don't try to set fd's flags to -1 if
authorThomas Wouters <thomas@python.org>
Fri, 31 Mar 2006 22:38:19 +0000 (22:38 +0000)
committerThomas Wouters <thomas@python.org>
Fri, 31 Mar 2006 22:38:19 +0000 (22:38 +0000)
fcntl() and fdopen() both fail. Will backport.

Modules/posixmodule.c

index a27a2af10064f71b3f945e0d9ae5af3bcec3bca2..50ee0e33925e97adfb6b7fb2115276fc8725c2be 100644 (file)
@@ -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 {