use `except as` to support python3