code: def setBuffer(self, buffer_or_len):
          
          if self.__submitted:
              raise ValueError('Cannot alter a submitted transfer')
          transfer = self.__transfer.contents
          # pylint: disable=undefined-variable
          if transfer.type == TRANSFER_TYPE_CONTROL:
              # pylint: enable=undefined-variable
              raise ValueError(
                  'To alter control transfer buffer, use setControl'
              )
          buff, transfer_py_buffer = create_binary_buffer(buffer_or_len)
          # pylint: disable=undefined-variable
          if transfer.type == TRANSFER_TYPE_ISOCHRONOUS and \
                  sizeof(buff) != transfer.length:
              # pylint: enable=undefined-variable
              raise ValueError(
                  'To alter isochronous transfer buffer length, use '
                  'setIsochronous'
              )
          self.__transfer_buffer = buff
          self.__transfer_py_buffer = transfer_py_buffer
          transfer.buffer = cast(buff, c_void_p)
          transfer.length = sizeof(buff)
docs: Replace buffer with a new one.
          Allows resizing read buffer and replacing data sent.
          Note: resizing is not allowed for isochronous buffer (use
          setIsochronous).
          Note: disallowed on control transfers (use setControl).