python: improved error reporting