Mercurial > evolve
changeset 4847:0fecff9ac36d
cmdstate: avoid setting a default argument to a mutable object (`{}`)
If there's ever more than one cmdstate for the lifetime of the process, this can
cause surprising behavior where the later cmdstates pick up options from the
earlier ones.
I've not seen any evidence this is actually causing any issues, but it's subtle
enough that it should probably be fixed to help save significant debugging time
later.
author | Kyle Lippincott <spectral@google.com> |
---|---|
date | Mon, 16 Sep 2019 12:42:50 -0700 |
parents | 38ce7fe4d3f2 |
children | 535ab2609e45 |
files | hgext3rd/evolve/state.py |
diffstat | 1 files changed, 3 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/state.py Mon Sep 16 12:42:11 2019 -0700 +++ b/hgext3rd/evolve/state.py Mon Sep 16 12:42:50 2019 -0700 @@ -37,9 +37,11 @@ can populate the object data reading that file """ - def __init__(self, repo, path=b'evolvestate', opts={}): + def __init__(self, repo, path=b'evolvestate', opts=None): self._repo = repo self.path = path + if opts is None: + opts = {} self.opts = opts def __nonzero__(self):