extensions: use context manger for open()
authorYuya Nishihara <yuya@tcha.org>
Sun, 17 Jun 2018 18:01:49 +0900
changeset 38344 c6f82a18a63d
parent 38343 2c1d983872f6
child 38345 bec1212eceaa
extensions: use context manger for open()
mercurial/extensions.py
--- a/mercurial/extensions.py	Sun Jun 17 17:59:12 2018 +0900
+++ b/mercurial/extensions.py	Sun Jun 17 18:01:49 2018 +0900
@@ -605,12 +605,10 @@
 def _disabledhelp(path):
     '''retrieve help synopsis of a disabled extension (without importing)'''
     try:
-        file = open(path, 'rb')
+        with open(path, 'rb') as src:
+            doc = _moduledoc(src)
     except IOError:
         return
-    else:
-        doc = _moduledoc(file)
-        file.close()
 
     if doc: # extracting localized synopsis
         return gettext(doc)