From: Benjamin Peterson Date: Sun, 31 Oct 2010 01:35:53 +0000 (+0000) Subject: close file properly X-Git-Tag: v3.2a4~233 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aa7cec0ac489990a9607c6231241a39921ba6ca5;p=python close file properly --- diff --git a/Lib/test/test_popen.py b/Lib/test/test_popen.py index da0c04eee6..accf187b54 100644 --- a/Lib/test/test_popen.py +++ b/Lib/test/test_popen.py @@ -22,7 +22,8 @@ class PopenTest(unittest.TestCase): def _do_test_commandline(self, cmdline, expected): cmd = '%s -c "import sys; print(sys.argv)" %s' cmd = cmd % (python, cmdline) - data = os.popen(cmd).read() + with os.popen(cmd) as p: + data = p.read() got = eval(data)[1:] # strip off argv[0] self.assertEqual(got, expected)