martinvonz created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers.
REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D6779 AFFECTED FILES mercurial/statprof.py CHANGE DETAILS diff --git a/mercurial/statprof.py b/mercurial/statprof.py --- a/mercurial/statprof.py +++ b/mercurial/statprof.py @@ -236,18 +236,14 @@ def getsource(self, length): if self.source is None: lineno = self.lineno - 1 - fp = None try: - fp = open(self.path, 'rb') - for i, line in enumerate(fp): - if i == lineno: - self.source = line.strip() - break + with open(self.path, 'rb') as fp: + for i, line in enumerate(fp): + if i == lineno: + self.source = line.strip() + break except: pass - finally: - if fp: - fp.close() if self.source is None: self.source = '' To: martinvonz, #hg-reviewers Cc: mercurial-devel _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel