This is the mail archive of the
mailing list for the GDB project.
Re: Python: avoid RuntimeError exception?
- From: Paul Koning <paulkoning at comcast dot net>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: gdb at sourceware dot org
- Date: Wed, 5 Oct 2011 15:20:23 -0400
- Subject: Re: Python: avoid RuntimeError exception?
- References: <F0DEE703-E378-4C62-9162-72B5C0F020B4@comcast.net> <email@example.com>
On Oct 5, 2011, at 2:17 PM, Tom Tromey wrote:
>>>>>> "Paul" == Paul Koning <firstname.lastname@example.org> 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> updating.
> 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.
Ok, makes sense to me. Thanks.