]> granicus.if.org Git - python/commitdiff
Fix ResourceWarning from subprocess pipes being left open.
authorBrian Curtin <brian.curtin@gmail.com>
Fri, 5 Nov 2010 15:40:27 +0000 (15:40 +0000)
committerBrian Curtin <brian.curtin@gmail.com>
Fri, 5 Nov 2010 15:40:27 +0000 (15:40 +0000)
Lib/test/test_quopri.py

index 2c52a3c025ad503b963633858ca1477ba7c7e57d..583fd456a489ed101a4f9a0e081730521e5d97f2 100644 (file)
@@ -178,6 +178,7 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz''')
         (p, e) = self.STRINGS[-1]
         process = subprocess.Popen([sys.executable, "-mquopri"],
                                    stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+        self.addCleanup(process.stdout.close)
         cout, cerr = process.communicate(p)
         # On Windows, Python will output the result to stdout using
         # CRLF, as the mode of stdout is text mode. To compare this
@@ -193,6 +194,7 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz''')
         (p, e) = self.STRINGS[-1]
         process = subprocess.Popen([sys.executable, "-mquopri", "-d"],
                                    stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+        self.addCleanup(process.stdout.close)
         cout, cerr = process.communicate(e)
         cout = cout.decode('latin-1')
         p = p.decode('latin-1')