def strip_esc_sequence(txt):
 if isinstance(txt, six.string_types):
  return txt.replace('\x1b', '?')
 else:
  return txt

def strip_esc_sequence ( txt ) : if isinstance ( txt , six . string_types ) : return txt . replace ( '\x1b' , '?' ) else : return txt
replace esc to prevent unsafe strings from writing their own terminal manipulation commands .