chiark / gitweb /
Using a mutable default function argument is bad
authorChuck Lever <cel@netapp.com>
Wed, 26 Oct 2005 18:51:54 +0000 (14:51 -0400)
committerCatalin Marinas <catalin.marinas@gmail.com>
Wed, 2 Nov 2005 21:48:56 +0000 (21:48 +0000)
commit9216b6023d6840c457172b375e14443189f7ef89
tree4a1c60aee1a314882fa1593b5d952cef13a902f2
parent7354d6941b555dd15a0fe9c9e46d4394cf92f01f
Using a mutable default function argument is bad

Python function arguments can have default values.  These values are
objects that are created when the "def" statement is run, not when the
function is called.  These objects are thus persistent across calls to
that function.  If a mutable object, such as a list, is used as a
default argument, that object will retain its value across function
calls.  This is potentially unwanted behavior if the function is called
multiple times.

Fix up function argument defaults in stgit/git.py, for safety.

Signed-off-by: Chuck Lever <cel@netapp.com>
stgit/git.py