Takayuki Shimizukawa avatar Takayuki Shimizukawa committed bcf6b5b

Fix ResourceWarnings with Python 3.2 or later. Closes #1269

Comments (0)

Files changed (2)

 
 * #1311: Fix test_linkcode.test_html fails with C locale and Python 3.
 
+* #1269: Fix ResourceWarnings with Python 3.2 or later.
+
 
 Release 1.2 beta3 (released Oct 3, 2013)
 ========================================

sphinx/builders/gettext.py

     :license: BSD, see LICENSE for details.
 """
 
+from __future__ import with_statement
+
 from os import path, walk
 from codecs import open
 from time import time
 
         for template in self.status_iterator(files,
                 'reading templates... ', purple, len(files)):
-            context = open(template, 'r', encoding='utf-8').read()
+            with open(template, 'r', encoding='utf-8') as f:
+                context = f.read()
             for line, meth, msg in extract_translations(context):
                 origin = MsgOrigin(template, line)
                 self.catalogs['sphinx'].add(msg, origin)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.