def _to_binary_string_py3(text):
 if isinstance(text, six.binary_type):
  return text
 elif isinstance(text, six.string_types):
  return six.b(text)
 else:
  raise Exception('only takes string types')

def _to_binary_string_py3 ( text ) : if isinstance ( text , six . binary_type ) : return text elif isinstance ( text , six . string_types ) : return six . b ( text ) else : raise Exception ( 'only takes string types' )
converts a string to a binary string if it is not already one .