def __match(self, chars, error_message):
        """Verify that the next N characters match chars,
        and consume them.  In case of a mismatch, raise an exception.
        Only supports low-ASCII characters.

        If error_message is None, we generate a default message."""
        start_pos = self.__scanner.position
      
        for i in range(0, len(chars)):
            expected = chars[i]
            if self.__scanner.at_end:
                actual = -1
            else:
                actual = self.__scanner.read_ubyte()
            if expected != actual:
                if error_message is not None:
                    self.__error(error_message, start_pos)
                else:
                    self.__error("Expected \"%s\"" % chars, start_pos)
dataset/ETHPy150Open scalyr/scalyr-agent-2/scalyr_agent/json_lib/parser.py/JsonParser.__match/original