Use six instead of try/except block