# HG changeset patch # User Simon Cross # Date 1302167131 -7200 # Node ID 8ea658969f4717949ca23bd8f89dc11e59fc9eef # Parent 479fb1e4d130c8047a7df0ba52870f8027dca77c Fix on_entry and on_exit handling. diff -r 479fb1e4d130 -r 8ea658969f47 skaapsteker/dialogue.py --- a/skaapsteker/dialogue.py Thu Apr 07 01:53:27 2011 +0200 +++ b/skaapsteker/dialogue.py Thu Apr 07 11:05:31 2011 +0200 @@ -98,12 +98,16 @@ self.on_entry = compile(on_entry, "<%s>" % ":".join(base_path + ["on_entry"]), "exec") + else: + self.on_entry = None on_exit = state_src.get("on_exit", None) if on_exit is not None: self.on_exit = compile(on_exit, "<%s>" % ":".join(base_path + ["on_exit"]), "exec") + else: + self.on_exit = None def __repr__(self): return "<%r name=%r>" % (self.__class__.__name__, self.name) @@ -115,10 +119,12 @@ return next_state def enter(self, my_locals): - self.on_entry(my_locals, {}, my_locals.copy()) + if self.on_entry is not None: + exec(self.on_entry, {}, my_locals.copy()) def leave(self, my_locals): - self.on_exit(my_locals, {}, my_locals.copy()) + if self.on_exit is not None: + exec(self.on_exit, {}, my_locals.copy()) class Trigger(object):