TST/BUG: hack around the weird scoping of exception catching in python3