# HG changeset patch # User Siddharth Agarwal # Date 2015-09-22 23:56:34 # Node ID 60558319ce724e8377c56591af3089380753f6de # Parent 60dd8e3977f02f1e5be82d517dcb0b35ccd53675 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. diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -834,7 +834,9 @@ class ui(object): 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 @@ class ui(object): 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. '''