From 654fd3e173e7e92f9ff1ee1e55caa5c2e7a96ad9 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 17 Oct 2011 22:45:13 -0700 Subject: [PATCH] python3.2 fixes: "ResourceWarning: unclosed file" --- pym/_emerge/EbuildMetadataPhase.py | 6 +++--- pym/portage/dbapi/porttree.py | 6 +++--- pym/portage/package/ebuild/doebuild.py | 7 ++++--- 3 files changed, 10 insertions(+), 9 deletions(-) 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): -- 2.26.2