summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/_emerge/BinpkgEnvExtractor.py2
-rw-r--r--pym/portage/dbapi/vartree.py15
-rw-r--r--pym/portage/xpak.py3
3 files changed, 14 insertions, 6 deletions
diff --git a/pym/_emerge/BinpkgEnvExtractor.py b/pym/_emerge/BinpkgEnvExtractor.py
index f68971b35..1c9471877 100644
--- a/pym/_emerge/BinpkgEnvExtractor.py
+++ b/pym/_emerge/BinpkgEnvExtractor.py
@@ -59,7 +59,7 @@ class BinpkgEnvExtractor(CompositeTask):
# This is a signal to ebuild.sh, so that it knows to filter
# out things like SANDBOX_{DENY,PREDICT,READ,WRITE} that
# would be preserved between normal phases.
- open(_unicode_encode(self._get_dest_env_path() + '.raw'), 'w')
+ open(_unicode_encode(self._get_dest_env_path() + '.raw'), 'wb').close()
self._current_task = None
self.returncode = os.EX_OK
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index 7f7873bd4..6e49f38f8 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -3192,17 +3192,22 @@ class dblink(object):
pass
continue
+ f = None
try:
- val = io.open(_unicode_encode(
+ f = io.open(_unicode_encode(
os.path.join(inforoot, var_name),
encoding=_encodings['fs'], errors='strict'),
mode='r', encoding=_encodings['repo.content'],
- errors='replace').readline().strip()
+ errors='replace')
+ val = f.readline().strip()
except EnvironmentError as e:
if e.errno != errno.ENOENT:
raise
del e
val = ''
+ finally:
+ if f is not None:
+ f.close()
if var_name == 'SLOT':
slot = val
@@ -3558,10 +3563,12 @@ class dblink(object):
# write local package counter for recording
if counter is None:
counter = self.vartree.dbapi.counter_tick(mycpv=self.mycpv)
- io.open(_unicode_encode(os.path.join(self.dbtmpdir, 'COUNTER'),
+ f = io.open(_unicode_encode(os.path.join(self.dbtmpdir, 'COUNTER'),
encoding=_encodings['fs'], errors='strict'),
mode='w', encoding=_encodings['repo.content'],
- errors='backslashreplace').write(_unicode_decode(str(counter)))
+ errors='backslashreplace')
+ f.write(_unicode_decode(str(counter)))
+ f.close()
self.updateprotect()
diff --git a/pym/portage/xpak.py b/pym/portage/xpak.py
index 01cfe7b0a..a05a86009 100644
--- a/pym/portage/xpak.py
+++ b/pym/portage/xpak.py
@@ -99,7 +99,8 @@ def xpak(rootdir,outfile=None):
# CONTENTS is generated during the merge process.
continue
x = _unicode_encode(x, encoding=_encodings['fs'], errors='strict')
- mydata[x] = open(os.path.join(rootdir, x), 'rb').read()
+ with open(os.path.join(rootdir, x), 'rb') as f:
+ mydata[x] = f.read()
xpak_segment = xpak_mem(mydata)
if outfile: