title: Detecting infinite recursion
body: <p>I'm creating a macro for <a href="http://trac.edgewall.org/" rel="nofollow">Trac</a>, and one of the things it does is to render a bit of wiki text, that can in turn use the same macro.</p>
  
  <p>This can give rise to an infinite recursion if the inner macro is invoked with the same arguments (i.e., renders the same bit of wiki text). I thought of trying to stop the user from shooting his own foot like this by inspecting the call stack and breaking the recursion if the function that expands the macro was already invoked with exactly the same set of arguments.</p>
  
  <p>I've been looking at the <a href="http://docs.python.org/2/library/inspect.html" rel="nofollow">inspect module</a>, which definitely seems like the way to go, but still couldn't figure out how to discover the argument values of the previous function on the stack. How can I do this?</p>