From f09994e5273e358c5fc764db681bd3dafecc3e2d Mon Sep 17 00:00:00 2001 From: Alex Martelli Date: Sun, 9 Nov 2003 16:44:09 +0000 Subject: [PATCH] fixed wrong error checking on fcntl call as per SF bug # 821896 (same as commit of Sun Nov 2 to the release23-maint branch) --- Lib/tempfile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/tempfile.py b/Lib/tempfile.py index 472fd83155b..1405a7f7424 100644 --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -47,8 +47,9 @@ except (ImportError, AttributeError): 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)