hacky fix for very strange exception catching failure under Python 3