From 888f65545a2fa0841d7592f44463b09a7a28f6eb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ville=20Skytt=C3=A4?= Date: Tue, 26 Jul 2016 23:30:06 +0300 Subject: [PATCH] Close files earlier --- babel/localedata.py | 2 +- babel/messages/frontend.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/babel/localedata.py b/babel/localedata.py index 9c6f9f2b..87981fe2 100644 --- a/babel/localedata.py +++ b/babel/localedata.py @@ -112,9 +112,9 @@ def load(name, merge_inherited=True): merge(data, pickle.load(fileobj)) else: data = pickle.load(fileobj) - _cache[name] = data finally: fileobj.close() + _cache[name] = data return data finally: _cache_lock.release() diff --git a/babel/messages/frontend.py b/babel/messages/frontend.py index 89a7b54a..a4e9c2e5 100644 --- a/babel/messages/frontend.py +++ b/babel/messages/frontend.py @@ -474,10 +474,10 @@ class extract_messages(Command): fileobj = open(self.mapping_file, 'U') try: method_map, options_map = parse_mapping(fileobj) - for path in self.input_paths: - mappings.append((path, method_map, options_map)) finally: fileobj.close() + for path in self.input_paths: + mappings.append((path, method_map, options_map)) elif getattr(self.distribution, 'message_extractors', None): message_extractors = self.distribution.message_extractors -- 2.47.2