use python3 compatible except and raise