code: def validate_bytes(data, length=4):
          '''
          Raises ValueError if data is not bytes.
          Raises ValueError if len(data) is not length.
          Length may be None for unknown lengths (e.g. scripts).
          length=None will allow 0 length data.
          '''
          if (not isinstance(data, ByteData)
                  and not isinstance(data, bytes)
                  and not isinstance(data, bytearray)):
              raise ValueError('Expected byte-like object. '
                               'Got: {}'.format(type(data)))
  
          if length is None:
              return
  
          if len(data) != length:
              raise ValueError('Expected byte-like object with length {}. '
                               'Got {} with length {}.'
                               .format(length, type(data), len(data))f validate_bytes(data, length=4):
          '''
          Raises ValueError if data is not bytes.
          Raises ValueError if len(data) is not length.
          Length may be None for unknown lengths (e.g. scripts).
          length=None will allow 0 length data.
          '''
          if (not isinstance(data, ByteData)
                  and not isinstance(data, bytes)
                  and not isinstance(data, bytearray)):
              raise ValueError('Expected byte-like object. '
                               'Got: {}'.format(type(data)))
  
          if length is None:
              return
  
          if len(data) != length:
              raise ValueError('Expected byte-like object with length {}. '
                               'Got {} with length {}.'
                               .format(length, type(data), len(data)))
docs: Raises ValueError if data is not bytes.
          Raises ValueError if len(data) is not length.
          Length may be None for unknown lengths (e.g. scripts).
          length=None will allow 0 length data.