cmdstate: avoid setting a default argument to a mutable object (`{}`)
authorKyle Lippincott <spectral@google.com>
Mon, 16 Sep 2019 12:42:50 -0700
changeset 4847 0fecff9ac36d
parent 4846 38ce7fe4d3f2
child 4848 535ab2609e45
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.
hgext3rd/evolve/state.py
--- 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):