def _to_bytes(value, encoding='ascii'):
 result = (value.encode(encoding) if isinstance(value, six.text_type) else value)
 if isinstance(result, six.binary_type):
  return result
 else:
  raise TypeError(('%r could not be converted to bytes' % (value,)))

def _to_bytes ( value , encoding = 'ascii' ) : result = ( value . encode ( encoding ) if isinstance ( value , six . text_type ) else value ) if isinstance ( result , six . binary_type ) : return result else : raise TypeError ( ( '%r could not be converted to bytes' % ( value , ) ) )
converts a string value to bytes .