# HG changeset patch # User Yuya Nishihara # Date 1529226109 -32400 # Node ID c6f82a18a63de52c95f0e6ee362ffd0fd4154ccd # Parent 2c1d983872f6049c73be18d5d9da938b1d61f8fd extensions: use context manger for open() diff -r 2c1d983872f6 -r c6f82a18a63d 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)