fixed wrong error checking on fcntl call as per SF bug # 821896
(same as commit of Sun Nov 2 to the release23-maint branch)
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
index 472fd83..1405a7f 100644
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -47,8 +47,9 @@
pass
else:
def _set_cloexec(fd):
- flags = _fcntl.fcntl(fd, _fcntl.F_GETFD, 0)
- if flags >= 0:
+ try: flags = _fcntl.fcntl(fd, _fcntl.F_GETFD, 0)
+ except IOError: pass
+ else:
# flags read successfully, modify
flags |= _fcntl.FD_CLOEXEC
_fcntl.fcntl(fd, _fcntl.F_SETFD, flags)