def safe_subn(pattern, repl, target, *args, **kwargs):
 return re.subn(str(pattern), str(repl), target, *args, **kwargs)

def safe_subn ( pattern , repl , target , * args , ** kwargs ) : return re . subn ( str ( pattern ) , str ( repl ) , target , * args , ** kwargs )
there are unicode conversion problems with re .