This is the mail archive of the
mailing list for the GDB project.
Re: Python: avoid RuntimeError exception?
- From: Tom Tromey <tromey at redhat dot com>
- To: Paul Koning <paulkoning at comcast dot net>
- Cc: gdb at sourceware dot org
- Date: Wed, 05 Oct 2011 12:17:38 -0600
- Subject: Re: Python: avoid RuntimeError exception?
- References: <F0DEE703-E378-4C62-9162-72B5C0F020B4@comcast.net>
>>>>> "Paul" == Paul Koning <email@example.com> writes:
Paul> The Python documentation (Library manual, builtin exceptions chapter)
Paul> implies that RuntimeError is used if nothing better is available,
Paul> i.e., it's sort of deprecated.
Paul> The GDB Python code uses it for most errors, even when a more natural
Paul> exception is also available. For example, looking up a structure
Paul> field in a gdb.Value object raises RuntimeError if the field is not
Paul> found, instead of the expected KeyError.
Paul> It would be good to tweak some of these to match Python conventions.
Paul> The drawback is that existing checks in existing scripts might need
Paul> What's the right answer?
I think we are just stuck with the code as we have shipped it, because I
value compatibility more than using the correct exception.
For new code we can try to do better.