def validate_plural_forms(plural_forms_str):
 tokens = tokenize.generate_tokens(StringIO(plural_forms_str).readline)
 try:
  danger = [x for x in tokens if ((x[0] == token.NAME) and (x[1] != 'n'))]
 except tokenize.TokenError:
  raise ValueError, 'plural forms expression error, maybe unbalanced parenthesis'
 else:
  if danger:
   raise ValueError, 'plural forms expression could be dangerous'

def validate_plural_forms ( plural_forms_str ) : tokens = tokenize . generate_tokens ( StringIO ( plural_forms_str ) . readline ) try : danger = [ x for x in tokens if ( ( x [ 0 ] == token . NAME ) and ( x [ 1 ] != 'n' ) ) ] except tokenize . TokenError : raise ValueError , 'plural forms expression error, maybe unbalanced parenthesis' else : if danger : raise ValueError , 'plural forms expression could be dangerous'
ensure the gettext plural forms expression supplied is valid .