def trunc_password(password):
 try:
  if (len(password) > MAX_PASSWORD_LENGTH):
   return password[:MAX_PASSWORD_LENGTH]
  else:
   return password
 except TypeError:
  raise exception.ValidationError(attribute='string', target='password')

def trunc_password ( password ) : try : if ( len ( password ) > MAX_PASSWORD_LENGTH ) : return password [ : MAX_PASSWORD_LENGTH ] else : return password except TypeError : raise exception . ValidationError ( attribute = 'string' , target = 'password' )
truncate passwords to the max_password_length .