From 276105a80d8fd1e6332a2dcb9733bf597fbcb0ed Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 28 Aug 2011 22:20:49 -0700 Subject: [PATCH] python3.2 fixes: ResourceWarning: unclosed file --- pym/portage/update.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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*$') -- 2.26.2