Mercurial > hg-stable
changeset 32824:2b0fc56840d0
profile: use explicit logic to control file closing
We make the decision to close 'fp' more explicit instead of relying on the
implication of other variable. This makes the overall logic more robust.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 12 Jun 2017 17:14:56 +0200 |
parents | c0b2c8f25ad9 |
children | 3a4c677cbd6e |
files | mercurial/profiling.py |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/profiling.py Mon Jun 12 17:13:35 2017 +0200 +++ b/mercurial/profiling.py Mon Jun 12 17:14:56 2017 +0200 @@ -151,6 +151,7 @@ self._ui = ui self._output = None self._fp = None + self._fpdoclose = True self._profiler = None self._enabled = enabled self._entered = False @@ -193,6 +194,7 @@ path = self._ui.expandpath(self._output) self._fp = open(path, 'wb') else: + self._fpdoclose = False self._fp = self._ui.ferr if proffn is not None: @@ -221,4 +223,5 @@ self._closefp() def _closefp(self): - self._fp.close() + if self._fpdoclose and self._fp is not None: + self._fp.close()