docs: def raise_on_packet(self, pkt_cls, state, get_next_msg=True):
          """
          If the next message to be processed has type 'pkt_cls', raise 'state'.
          If there is no message waiting to be processed, we try to get one with
          the default 'get_next_msg' parameters.
          """
          # Maybe we already parsed the expected packet, maybe not.
          if get_next_msg:
              self.get_next_msg()
          if (not self.buffer_in or
                  not isinstance(self.buffer_in[0], pkt_cls)):
              return
          self.cur_pkt = self.buffer_in[0]
          self.buffer_in = self.buffer_in[1:]
          raise state()