[Python-checkins] cpython (3.2): Fix ResourceWarnings in test_pty

antoine.pitrou python-checkins at python.org
Sun Dec 16 16:13:36 CET 2012


http://hg.python.org/cpython/rev/2ecea81adab0
changeset:   80886:2ecea81adab0
branch:      3.2
parent:      80883:96f19274de18
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Sun Dec 16 16:09:11 2012 +0100
summary:
  Fix ResourceWarnings in test_pty

files:
  Lib/test/test_pty.py |  8 +++++---
  1 files changed, 5 insertions(+), 3 deletions(-)


diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py
--- a/Lib/test/test_pty.py
+++ b/Lib/test/test_pty.py
@@ -215,7 +215,7 @@
         for fd in self.fds:
             try:
                 os.close(fd)
-            except:
+            except OSError:
                 pass
 
     def _pipe(self):
@@ -235,8 +235,9 @@
         mock_stdin_fd, write_to_stdin_fd = self._pipe()
         pty.STDIN_FILENO = mock_stdin_fd
         socketpair = socket.socketpair()
+        for s in socketpair:
+            self.addCleanup(s.close)
         masters = [s.fileno() for s in socketpair]
-        self.fds.extend(masters)
 
         # Feed data.  Smaller than PIPEBUF.  These writes will not block.
         os.write(masters[1], b'from master')
@@ -264,8 +265,9 @@
         mock_stdin_fd, write_to_stdin_fd = self._pipe()
         pty.STDIN_FILENO = mock_stdin_fd
         socketpair = socket.socketpair()
+        for s in socketpair:
+            self.addCleanup(s.close)
         masters = [s.fileno() for s in socketpair]
-        self.fds.extend(masters)
 
         os.close(masters[1])
         socketpair[1].close()

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list