def _format_assertmsg(obj):
 if (py.builtin._istext(obj) or py.builtin._isbytes(obj)):
  s = obj
  is_repr = False
 else:
  s = py.io.saferepr(obj)
  is_repr = True
 if py.builtin._istext(s):
  t = py.builtin.text
 else:
  t = py.builtin.bytes
 s = s.replace(t('\n'), t('\n~')).replace(t('%'), t('%%'))
 if is_repr:
  s = s.replace(t('\\n'), t('\n~'))
 return s

def _format_assertmsg ( obj ) : if ( py . builtin . _istext ( obj ) or py . builtin . _isbytes ( obj ) ) : s = obj is_repr = False else : s = py . io . saferepr ( obj ) is_repr = True if py . builtin . _istext ( s ) : t = py . builtin . text else : t = py . builtin . bytes s = s . replace ( t ( '\n' ) , t ( '\n~' ) ) . replace ( t ( '%' ) , t ( '%%' ) ) if is_repr : s = s . replace ( t ( '\\n' ) , t ( '\n~' ) ) return s
format the custom assertion message given .