Mercurial > hg
diff mercurial/extensions.py @ 38344:c6f82a18a63d
extensions: use context manger for open()
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 17 Jun 2018 18:01:49 +0900 |
parents | 2c1d983872f6 |
children | fcb517ff9562 |
line wrap: on
line diff
--- 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)