util: use a context manager in readlock()
authorMatt Harbison <matt_harbison@yahoo.com>
Fri, 28 Sep 2018 22:18:45 -0400
changeset 39905 4017968f0a1d
parent 39904 5fe0b880200e
child 39906 2327abace563
util: use a context manager in readlock()
mercurial/util.py
--- a/mercurial/util.py	Tue Sep 25 21:16:12 2018 -0400
+++ b/mercurial/util.py	Fri Sep 28 22:18:45 2018 -0400
@@ -1848,10 +1848,8 @@
             raise
     except AttributeError: # no symlink in os
         pass
-    fp = posixfile(pathname, 'rb')
-    r = fp.read()
-    fp.close()
-    return r
+    with posixfile(pathname, 'rb') as fp:
+        return fp.read()
 
 def fstat(fp):
     '''stat file object that may not have fileno method.'''