code: def PopState(self, **unused_kwargs):
      
      try:
        self.state = self.state_stack.pop()
        logging.debug('Returned state to {0:s}'.format(self.state))
  
        return self.state
      except IndexError:
        self.Error(
            'Tried to pop the state but failed - possible recursion error')
docs: Pop the previous state from the stack.