python3.2 fixes: ResourceWarning: unclosed file
authorZac Medico <zmedico@gentoo.org>
Fri, 26 Aug 2011 15:43:02 +0000 (08:43 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 26 Aug 2011 15:43:02 +0000 (08:43 -0700)
pym/_emerge/actions.py
pym/portage/tests/repoman/test_simple.py
pym/portage/util/_dyn_libs/LinkageMapELF.py

index 21669638ec8f153d1247458cffb6cf2db26cb5d6..882a2db42eee748cfb4ade556d1f2463b8f58ae7 100644 (file)
@@ -13,6 +13,7 @@ import shutil
 import signal
 import socket
 import stat
+import subprocess
 import sys
 import tempfile
 import textwrap
@@ -2883,10 +2884,10 @@ def git_sync_timestamps(settings, portdir):
        args = [portage.const.BASH_BINARY, "-c",
                "cd %s && git diff-index --name-only --diff-filter=M HEAD" % \
                portage._shell_quote(portdir)]
-       import subprocess
        proc = subprocess.Popen(args, stdout=subprocess.PIPE)
        modified_files = set(_unicode_decode(l).rstrip("\n") for l in proc.stdout)
        rval = proc.wait()
+       proc.stdout.close()
        if rval != os.EX_OK:
                return rval
 
index 612ff8e77782045d9c5a62e27209abf12d98a535..b987f296fc65f0a904ed5ec1a64f71939cc1f14b 100644 (file)
@@ -154,7 +154,9 @@ class SimpleRepomanTestCase(TestCase):
                                        os.path.join(PORTAGE_BIN_PATH, "repoman"), "full"],
                                        cwd=cwd, env=env, stdout=subprocess.PIPE)
                                output = proc.stdout.readlines()
-                               if proc.wait() != os.EX_OK:
+                               proc.wait()
+                               proc.stdout.close()
+                               if proc.returncode != os.EX_OK:
                                        for line in output:
                                                sys.stderr.write(_unicode_decode(line))
 
index 52670d98dd9552cd6bb6161c07860fb970c1e62d..f7513573db67b55d18fb26ec4afce969bbbbe244 100644 (file)
@@ -267,6 +267,7 @@ class LinkageMapELF(object):
                                        owner = plibs.pop(fields[1], None)
                                        lines.append((owner, "scanelf", ";".join(fields)))
                                proc.wait()
+                               proc.stdout.close()
 
                if plibs:
                        # Preserved libraries that did not appear in the scanelf output.