quick patch for better debugging

Both IndexError and KeyError dont report which object the retrieval failed on. Having this data would save lots of typing and annoyance. Eg: KeyError: 'jio' could look like KeyError: "Dictionary(some_name) has no key 'jio'" IndexError: list index out of range could look like: IndexError: list(some_name) index(some_value) out of range If this is ok, ill make a patch! ----- PS: And for those of you that think even more debugging info is needed, think no more, because I prodded enough a few months ago such that textmode cgitb is now in 2.3 tree. Try: import cgitb; cgitb.enable(format='text') make error here. -- Hunter Peress hunterp@fastmail.fm

Hunter Peress <hunterp@fastmail.fm>:
I agree with the general idea of providing some sort of identifying information, but in these cases I can't think what sort of information would be useful short of displaying the entire repr() of the object, which would be too much for a backtrace message, I think. Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg@cosc.canterbury.ac.nz +--------------------------------------+

On Sunday 23 November 2003 08:05 pm, Greg Ewing wrote:
You don't have to include the offending index/key in the __str__ of the exception itself. Even if it was just available in the exception's args tuple, or even as an attribute on the exception object, it'd still be highly useful as a debugging tool. I've wished for this myself on several occasions. Jeremy

Hunter Peress <hunterp@fastmail.fm>:
I agree with the general idea of providing some sort of identifying information, but in these cases I can't think what sort of information would be useful short of displaying the entire repr() of the object, which would be too much for a backtrace message, I think. Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg@cosc.canterbury.ac.nz +--------------------------------------+

On Sunday 23 November 2003 08:05 pm, Greg Ewing wrote:
You don't have to include the offending index/key in the __str__ of the exception itself. Even if it was just available in the exception's args tuple, or even as an attribute on the exception object, it'd still be highly useful as a debugging tool. I've wished for this myself on several occasions. Jeremy
participants (3)
-
Greg Ewing
-
Hunter Peress
-
Jeremy Fincher