Python 3 compat; more robust edit_string_for_array