[python] Catch KeyError in Python