def escape_byte_string(s):
 s = _replace_specials(s)
 try:
  return s.decode('ASCII')
 except UnicodeDecodeError:
  pass
 if IS_PYTHON3:
  s_new = bytearray()
  (append, extend) = (s_new.append, s_new.extend)
  for b in s:
   if (b >= 128):
    extend(('\\%3o' % b).encode('ASCII'))
   else:
    append(b)
  return s_new.decode('ISO-8859-1')
 else:
  l = []
  append = l.append
  for c in s:
   o = ord(c)
   if (o >= 128):
    append(('\\%3o' % o))
   else:
    append(c)
  return join_bytes(l).decode('ISO-8859-1')

def escape_byte_string ( s ) : s = _replace_specials ( s ) try : return s . decode ( 'ASCII' ) except UnicodeDecodeError : pass if IS_PYTHON3 : s_new = bytearray ( ) ( append , extend ) = ( s_new . append , s_new . extend ) for b in s : if ( b >= 128 ) : extend ( ( '\\%3o' % b ) . encode ( 'ASCII' ) ) else : append ( b ) return s_new . decode ( 'ISO-8859-1' ) else : l = [ ] append = l . append for c in s : o = ord ( c ) if ( o >= 128 ) : append ( ( '\\%3o' % o ) ) else : append ( c ) return join_bytes ( l ) . decode ( 'ISO-8859-1' )
escape a byte string so that it can be written into c code .