python3.2 fixes: "ResourceWarning: unclosed file"
authorZac Medico <zmedico@gentoo.org>
Tue, 18 Oct 2011 05:45:13 +0000 (22:45 -0700)
committerZac Medico <zmedico@gentoo.org>
Tue, 18 Oct 2011 05:45:13 +0000 (22:45 -0700)
pym/_emerge/EbuildMetadataPhase.py
pym/portage/dbapi/porttree.py
pym/portage/package/ebuild/doebuild.py

index 06cabe7d152a37ec3d3976592cde1200b5da6285..aa26e1928c260a9335cf428b19b48d6a68d0d05d 100644 (file)
@@ -38,11 +38,11 @@ class EbuildMetadataPhase(SubProcess):
                eapi = self.eapi
                if eapi is None and \
                        'parse-eapi-ebuild-head' in settings.features:
-                       eapi = portage._parse_eapi_ebuild_head(
-                               io.open(_unicode_encode(ebuild_path,
+                       with io.open(_unicode_encode(ebuild_path,
                                encoding=_encodings['fs'], errors='strict'),
                                mode='r', encoding=_encodings['repo.content'],
-                               errors='replace'))
+                               errors='replace') as f:
+                               eapi = portage._parse_eapi_ebuild_head(f)
 
                if eapi is not None:
                        if not portage.eapi_is_supported(eapi):
index aad72e14439135922c8403ce8bfddc24011be9b0..6f3d90f735593f917a2869fca8eb53b1a2f11022 100644 (file)
@@ -519,11 +519,11 @@ class portdbapi(dbapi):
 
                        if eapi is None and \
                                'parse-eapi-ebuild-head' in self.doebuild_settings.features:
-                               eapi = portage._parse_eapi_ebuild_head(io.open(
-                                       _unicode_encode(myebuild,
+                               with io.open(_unicode_encode(myebuild,
                                        encoding=_encodings['fs'], errors='strict'),
                                        mode='r', encoding=_encodings['repo.content'],
-                                       errors='replace'))
+                                       errors='replace') as f:
+                                       eapi = portage._parse_eapi_ebuild_head(f)
 
                        if eapi is not None:
                                self.doebuild_settings.configdict['pkg']['EAPI'] = eapi
index e479159072e9707ab7b1e6da6cb38ea45d6db5bc..a324af2de3682220edb2b53467e94eb35a991e1d 100644 (file)
@@ -290,10 +290,11 @@ def doebuild_environment(myebuild, mydo, myroot=None, settings=None,
        eapi = None
        if mydo == 'depend' and 'EAPI' not in mysettings.configdict['pkg']:
                if eapi is None and 'parse-eapi-ebuild-head' in mysettings.features:
-                       eapi = _parse_eapi_ebuild_head(
-                               io.open(_unicode_encode(ebuild_path,
+                       with io.open(_unicode_encode(ebuild_path,
                                encoding=_encodings['fs'], errors='strict'),
-                               mode='r', encoding=_encodings['content'], errors='replace'))
+                               mode='r', encoding=_encodings['content'],
+                               errors='replace') as f:
+                               eapi = _parse_eapi_ebuild_head(f)
 
                if eapi is not None:
                        if not eapi_is_supported(eapi):