Mercurial > hg
changeset 26312:60558319ce72
ui: avoid mutable default arguments
I almost introduced a bug around this code by accidentally mutating a default
argument. There's no reason for these to exist.
It is OK to not assign {} to environ in ui.system because util.system knows how
to deal with that.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Tue, 22 Sep 2015 16:56:34 -0700 |
parents | 60dd8e3977f0 |
children | e8afd380c576 |
files | mercurial/ui.py |
diffstat | 1 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/ui.py Tue Sep 22 16:55:18 2015 -0700 +++ b/mercurial/ui.py Tue Sep 22 16:56:34 2015 -0700 @@ -834,7 +834,9 @@ if self.debugflag: opts['label'] = opts.get('label', '') + ' ui.debug' self.write(*msg, **opts) - def edit(self, text, user, extra={}, editform=None): + def edit(self, text, user, extra=None, editform=None): + if extra is None: + extra = {} (fd, name) = tempfile.mkstemp(prefix="hg-editor-", suffix=".txt", text=True) try: @@ -866,7 +868,7 @@ return t - def system(self, cmd, environ={}, cwd=None, onerr=None, errprefix=None): + def system(self, cmd, environ=None, cwd=None, onerr=None, errprefix=None): '''execute shell command with appropriate output stream. command output will be redirected if fout is not stdout. '''