fixed exception handling syntax for python3 compatibility