From 69a45726b314f4f859f4783f4a5a5927a3f36bf5 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 26 Aug 2011 08:43:02 -0700 Subject: [PATCH] python3.2 fixes: ResourceWarning: unclosed file --- pym/_emerge/actions.py | 3 ++- pym/portage/tests/repoman/test_simple.py | 4 +++- pym/portage/util/_dyn_libs/LinkageMapELF.py | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index 21669638e..882a2db42 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -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 diff --git a/pym/portage/tests/repoman/test_simple.py b/pym/portage/tests/repoman/test_simple.py index 612ff8e77..b987f296f 100644 --- a/pym/portage/tests/repoman/test_simple.py +++ b/pym/portage/tests/repoman/test_simple.py @@ -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)) diff --git a/pym/portage/util/_dyn_libs/LinkageMapELF.py b/pym/portage/util/_dyn_libs/LinkageMapELF.py index 52670d98d..f7513573d 100644 --- a/pym/portage/util/_dyn_libs/LinkageMapELF.py +++ b/pym/portage/util/_dyn_libs/LinkageMapELF.py @@ -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. -- 2.26.2