Python: avoid RuntimeError exception?

Paul Koning paulkoning@comcast.net
Tue Sep 20 20:56:00 GMT 2011


The Python documentation (Library manual, builtin exceptions chapter) implies that RuntimeError is used if nothing better is available, i.e., it's sort of deprecated.

The GDB Python code uses it for most errors, even when a more natural exception is also available.  For example, looking up a structure field in a gdb.Value object raises RuntimeError if the field is not found, instead of the expected KeyError.

It would be good to tweak some of these to match Python conventions.  The drawback is that existing checks in existing scripts might need updating.

What's the right answer?

	paul



More information about the Gdb mailing list