make try except block python3 compatible