Mercurial > hg-stable
changeset 38350: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 | bec1212eceaa |
files | mercurial/extensions.py |
diffstat | 1 files changed, 2 insertions(+), 4 deletions(-) [+] |
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)