python lib: fix error message in try-except block