Mercurial > public > mercurial-scm > hg
diff mercurial/match.py @ 52578:bbb43c5b753a
match: don't leak a file descriptor when I/O fails reading a pattern file
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 17 Dec 2024 01:18:54 -0500 |
parents | a58f7f809fa5 |
children | 24ee91ba9aa8 |
line wrap: on
line diff
--- a/mercurial/match.py Tue Dec 17 01:16:59 2024 -0500 +++ b/mercurial/match.py Tue Dec 17 01:18:54 2024 -0500 @@ -1736,8 +1736,7 @@ syntax = b'relre:' patterns = [] - fp = open(filepath, 'rb') - if True: + with open(filepath, 'rb') as fp: for lineno, line in enumerate(fp, start=1): if b"#" in line: global _commentre @@ -1779,5 +1778,5 @@ patterns.append((linesyntax + line, lineno, line)) else: patterns.append(linesyntax + line) - fp.close() + return patterns