summaryrefslogtreecommitdiff
path: root/sleekxmpp/thirdparty/statemachine.py
diff options
context:
space:
mode:
authorMike Taylor <bear42@gmail.com>2015-04-11 20:12:19 -0400
committerMike Taylor <bear42@gmail.com>2015-04-11 20:12:19 -0400
commit86e85f98357b40941fddb7a2dbf8fbe16f96032e (patch)
tree65a86c0378c5e59f1822dfba8ed484f77ff5ebeb /sleekxmpp/thirdparty/statemachine.py
parentcc145d20b077442b7d4118d4d2f4c27e1b0faf0c (diff)
parent073e85381a86069e931369bb5353cab2a2e3682d (diff)
downloadslixmpp-86e85f98357b40941fddb7a2dbf8fbe16f96032e.tar.gz
slixmpp-86e85f98357b40941fddb7a2dbf8fbe16f96032e.tar.bz2
slixmpp-86e85f98357b40941fddb7a2dbf8fbe16f96032e.tar.xz
slixmpp-86e85f98357b40941fddb7a2dbf8fbe16f96032e.zip
Merge pull request #313 from mayflower/develop
Proposing #310 again in fixed version
Diffstat (limited to 'sleekxmpp/thirdparty/statemachine.py')
-rw-r--r--sleekxmpp/thirdparty/statemachine.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/sleekxmpp/thirdparty/statemachine.py b/sleekxmpp/thirdparty/statemachine.py
index 113320fa..6c504dce 100644
--- a/sleekxmpp/thirdparty/statemachine.py
+++ b/sleekxmpp/thirdparty/statemachine.py
@@ -34,7 +34,7 @@ class StateMachine(object):
self.lock.release()
- def transition(self, from_state, to_state, wait=0.0, func=None, args=[], kwargs={}):
+ def transition(self, from_state, to_state, wait=0.0, func=None, args=None, kwargs=None):
'''
Transition from the given `from_state` to the given `to_state`.
This method will return `True` if the state machine is now in `to_state`. It
@@ -65,15 +65,23 @@ class StateMachine(object):
values for `args` and `kwargs` are provided, they are expanded and passed like so:
`func( *args, **kwargs )`.
'''
+ if not args:
+ args = []
+ if not kwargs:
+ kwargs = {}
return self.transition_any((from_state,), to_state, wait=wait,
func=func, args=args, kwargs=kwargs)
- def transition_any(self, from_states, to_state, wait=0.0, func=None, args=[], kwargs={}):
+ def transition_any(self, from_states, to_state, wait=0.0, func=None, args=None, kwargs=None):
'''
Transition from any of the given `from_states` to the given `to_state`.
'''
+ if not args:
+ args = []
+ if not kwargs:
+ kwargs = {}
if not isinstance(from_states, (tuple, list, set)):
raise ValueError("from_states should be a list, tuple, or set")