This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Python: avoid RuntimeError exception?


>>>>> "Paul" == Paul Koning <paulkoning@comcast.net> 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.

Tom


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]