Python3 exception handling syntax fix