[Python-checkins] r72525 - python/trunk/Lib/gettext.py
benjamin.peterson
python-checkins at python.org
Sun May 10 03:38:02 CEST 2009
Author: benjamin.peterson
Date: Sun May 10 03:38:02 2009
New Revision: 72525
Log:
close file explicitly
Modified:
python/trunk/Lib/gettext.py
Modified: python/trunk/Lib/gettext.py
==============================================================================
--- python/trunk/Lib/gettext.py (original)
+++ python/trunk/Lib/gettext.py Sun May 10 03:38:02 2009
@@ -467,7 +467,6 @@
if fallback:
return NullTranslations()
raise IOError(ENOENT, 'No translation file found for domain', domain)
- # TBD: do we need to worry about the file pointer getting collected?
# Avoid opening, reading, and parsing the .mo file after it's been done
# once.
result = None
@@ -475,7 +474,8 @@
key = os.path.abspath(mofile)
t = _translations.get(key)
if t is None:
- t = _translations.setdefault(key, class_(open(mofile, 'rb')))
+ with open(mofile, 'rb') as fp:
+ t = _translations.setdefault(key, class_(fp))
# Copy the translation object to allow setting fallbacks and
# output charset. All other instance data is shared with the
# cached object.
More information about the Python-checkins
mailing list