diff options
Diffstat (limited to 'sphinx/util/pycompat.py')
-rw-r--r-- | sphinx/util/pycompat.py | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/sphinx/util/pycompat.py b/sphinx/util/pycompat.py index 44f51eaeb..0f7980e82 100644 --- a/sphinx/util/pycompat.py +++ b/sphinx/util/pycompat.py @@ -105,11 +105,8 @@ def execfile_(filepath, _globals, open=open): from sphinx.util.osutil import fs_encoding # get config source -- 'b' is a no-op under 2.x, while 'U' is # ignored under 3.x (but 3.x compile() accepts \r\n newlines) - f = open(filepath, 'rbU') - try: + with open(filepath, 'rbU') as f: source = f.read() - finally: - f.close() # py26 accept only LF eol instead of CRLF if sys.version_info[:2] == (2, 6): |