summaryrefslogtreecommitdiff
path: root/logilab
diff options
context:
space:
mode:
authorDenis Laxalde <denis.laxalde@logilab.fr>2017-07-04 09:25:01 +0200
committerDenis Laxalde <denis.laxalde@logilab.fr>2017-07-04 09:25:01 +0200
commitefe27c4a0250b0ac3726e64813e5ff157e51e814 (patch)
tree77ff4ee8e817e8e0957f65fa917ac48e9452c116 /logilab
parent6a832d17a3555c652d5530625a40f73c69441720 (diff)
downloadlogilab-common-efe27c4a0250b0ac3726e64813e5ff157e51e814.tar.gz
Use a context manager for io.open()
Diffstat (limited to 'logilab')
-rw-r--r--logilab/common/fileutils.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/logilab/common/fileutils.py b/logilab/common/fileutils.py
index 48828fb..93439d3 100644
--- a/logilab/common/fileutils.py
+++ b/logilab/common/fileutils.py
@@ -283,10 +283,8 @@ def lines(path, comments=None):
:warning: at some point this function will probably return an iterator
"""
- stream = io.open(path)
- result = stream_lines(stream, comments)
- stream.close()
- return result
+ with io.open(path) as stream:
+ return stream_lines(stream, comments)
def stream_lines(stream, comments=None):