def append(self, val):
        """Append byte string val to buffer
        If the result exceeds the length of the buffer, behavior
        depends on whether instance was initialized as strict.
        In strict mode, a ValueError is raised.
        In non-strict mode, the buffer is extended as necessary.
        """
        new_len = self.length + len(val)
        to_add = new_len - len(self.bfr)
        if self.strict and to_add > 0:
            raise ValueError("Cannot resize buffer")
        self.bfr[self.length:new_len] = val
        self.length = new_len