From: Zac Medico Date: Tue, 18 Oct 2011 05:45:13 +0000 (-0700) Subject: python3.2 fixes: "ResourceWarning: unclosed file" X-Git-Tag: v2.2.0_alpha69~3 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=654fd3e173e7e92f9ff1ee1e55caa5c2e7a96ad9;p=portage.git python3.2 fixes: "ResourceWarning: unclosed file" --- diff --git a/pym/_emerge/EbuildMetadataPhase.py b/pym/_emerge/EbuildMetadataPhase.py index 06cabe7d1..aa26e1928 100644 --- a/pym/_emerge/EbuildMetadataPhase.py +++ b/pym/_emerge/EbuildMetadataPhase.py @@ -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): diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index aad72e144..6f3d90f73 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -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 diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py index e47915907..a324af2de 100644 --- a/pym/portage/package/ebuild/doebuild.py +++ b/pym/portage/package/ebuild/doebuild.py @@ -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):