This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Python: avoid RuntimeError exception?
- From: Paul Koning <paulkoning at comcast dot net>
- To: gdb at sourceware dot org
- Date: Tue, 20 Sep 2011 16:55:54 -0400
- Subject: Python: avoid RuntimeError exception?
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