From: Zac Medico Date: Mon, 29 Aug 2011 05:20:49 +0000 (-0700) Subject: python3.2 fixes: ResourceWarning: unclosed file X-Git-Tag: v2.2.0_alpha52~41 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=276105a80d8fd1e6332a2dcb9733bf597fbcb0ed;p=portage.git python3.2 fixes: ResourceWarning: unclosed file --- diff --git a/pym/portage/update.py b/pym/portage/update.py index 548d19cef..1a2c86cc2 100644 --- a/pym/portage/update.py +++ b/pym/portage/update.py @@ -253,14 +253,19 @@ def update_config_files(config_root, protect, protect_mask, update_iter, match_c recursivefiles.append(x) myxfiles = recursivefiles for x in myxfiles: + f = None try: - file_contents[x] = io.open( + f = io.open( _unicode_encode(os.path.join(abs_user_config, x), encoding=_encodings['fs'], errors='strict'), mode='r', encoding=_encodings['content'], - errors='replace').readlines() + errors='replace') + file_contents[x] = f.readlines() except IOError: continue + finally: + if f is not None: + f.close() # update /etc/portage/packages.* ignore_line_re = re.compile(r'^#|^\s*$')