From: Ville Skyttä Date: Tue, 26 Jul 2016 20:30:06 +0000 (+0300) Subject: Close files earlier X-Git-Tag: v2.4.0~13^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=888f65545a2fa0841d7592f44463b09a7a28f6eb;p=thirdparty%2Fbabel.git Close files earlier --- 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