From 5a24743e55acedcbae06b97401c6e39b0d5faa98 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 25 Aug 2011 14:48:45 -0700 Subject: python3.2 fixes: ResourceWarning: unclosed file --- bin/repoman | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/repoman b/bin/repoman index 10f603ea2..e0494d95e 100755 --- a/bin/repoman +++ b/bin/repoman @@ -1228,11 +1228,13 @@ for x in scanlist: if not (y in ("ChangeLog", "metadata.xml") or y.endswith(".ebuild")): continue + f = None try: line = 1 - for l in io.open(_unicode_encode(os.path.join(checkdir, y), + f = io.open(_unicode_encode(os.path.join(checkdir, y), encoding=_encodings['fs'], errors='strict'), - mode='r', encoding=_encodings['repo.content']): + mode='r', encoding=_encodings['repo.content']) + for l in f: line +=1 except UnicodeDecodeError as ue: stats["file.UTF8"] += 1 @@ -1242,6 +1244,9 @@ for x in scanlist: if l2 != 0: s = s[s.rfind("\n") + 1:] fails["file.UTF8"].append("%s/%s: line %i, just after: '%s'" % (checkdir, y, line, s)) + finally: + if f is not None: + f.close() if vcs in ("git", "hg") and check_ebuild_notadded: if vcs == "git": -- cgit v1.2.3-1-g7c22