diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-02-19 04:22:03 +0000 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-02-19 04:22:03 +0000 |
commit | d75fcb4ddfb76b290083982e44b80582ab13aae2 (patch) | |
tree | 0d9a58da6e89a9d44d07546d32770b7adb029c8e /Lib | |
parent | Blocked revisions 69748,69751 via svnmerge (diff) | |
download | cpython-d75fcb4ddfb76b290083982e44b80582ab13aae2.tar.gz cpython-d75fcb4ddfb76b290083982e44b80582ab13aae2.tar.bz2 cpython-d75fcb4ddfb76b290083982e44b80582ab13aae2.zip |
Merged revisions 69576,69579-69580,69589,69619-69620,69633,69703-69704,69728-69730 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r69576 | georg.brandl | 2009-02-13 04:56:50 -0600 (Fri, 13 Feb 2009) | 1 line
#1661108: note that urlsafe encoded string can contain "=".
........
r69579 | georg.brandl | 2009-02-13 05:06:59 -0600 (Fri, 13 Feb 2009) | 2 lines
Fix warnings GCC emits where the argument of PyErr_Format is a single variable.
........
r69580 | georg.brandl | 2009-02-13 05:10:04 -0600 (Fri, 13 Feb 2009) | 2 lines
Fix warnings GCC emits where the argument of PyErr_Format is a single variable.
........
r69589 | martin.v.loewis | 2009-02-13 14:11:34 -0600 (Fri, 13 Feb 2009) | 2 lines
Move amd64 properties further to the top, so that they override
the linker options correctly.
........
r69619 | benjamin.peterson | 2009-02-14 11:00:51 -0600 (Sat, 14 Feb 2009) | 1 line
this needn't be a shebang line
........
r69620 | georg.brandl | 2009-02-14 11:01:36 -0600 (Sat, 14 Feb 2009) | 1 line
#5179: don't leak PIPE fds when child execution fails.
........
r69633 | hirokazu.yamamoto | 2009-02-15 03:19:48 -0600 (Sun, 15 Feb 2009) | 1 line
Fixed typo.
........
r69703 | raymond.hettinger | 2009-02-16 16:42:54 -0600 (Mon, 16 Feb 2009) | 3 lines
Issue 5229: Documentation for super() neglects to say what super() actually does
........
r69704 | raymond.hettinger | 2009-02-16 17:00:25 -0600 (Mon, 16 Feb 2009) | 1 line
Add explanation for super(type1, type2).
........
r69728 | georg.brandl | 2009-02-17 18:22:55 -0600 (Tue, 17 Feb 2009) | 2 lines
#5297: fix example.
........
r69729 | georg.brandl | 2009-02-17 18:25:13 -0600 (Tue, 17 Feb 2009) | 2 lines
#5296: sequence -> iterable.
........
r69730 | georg.brandl | 2009-02-17 18:31:36 -0600 (Tue, 17 Feb 2009) | 2 lines
#5268: mention VMSError.
........
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/subprocess.py | 3 | ||||
-rw-r--r-- | Lib/test/test_pep263.py | 2 | ||||
-rw-r--r-- | Lib/test/test_subprocess.py | 16 |
3 files changed, 20 insertions, 1 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py index 391edcae1e2..bd158f66601 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -1139,6 +1139,9 @@ class Popen(object): if data: os.waitpid(self.pid, 0) child_exception = pickle.loads(data) + for fd in (p2cwrite, c2pread, errread): + if fd is not None: + os.close(fd) raise child_exception diff --git a/Lib/test/test_pep263.py b/Lib/test/test_pep263.py index 106b3abc1cc..72764f9935d 100644 --- a/Lib/test/test_pep263.py +++ b/Lib/test/test_pep263.py @@ -1,4 +1,4 @@ -#! -*- coding: koi8-r -*- +# -*- coding: koi8-r -*- import unittest from test import support diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index eb4e759336e..5d3e040a557 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -521,6 +521,22 @@ class ProcessTestCase(unittest.TestCase): p = subprocess.Popen([sys.executable, "-c", "pass"], bufsize=None) self.assertEqual(p.wait(), 0) + def test_leaking_fds_on_error(self): + # see bug #5179: Popen leaks file descriptors to PIPEs if + # the child fails to execute; this will eventually exhaust + # the maximum number of open fds. 1024 seems a very common + # value for that limit, but Windows has 2048, so we loop + # 1024 times (each call leaked two fds). + for i in range(1024): + try: + subprocess.Popen(['nonexisting_i_hope'], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + # Windows raises IOError + except (IOError, OSError) as err: + if err.errno != 2: # ignore "no such file" + pass # XXX see #5312 + # # POSIX tests # |