Error message repetition

Tambet qtvali at gmail.com
Wed Jul 7 11:10:27 EDT 2010


Hello!

I have such problem that:

   - My console shows maximally x last lines, then truncates
   - Error message takes 2 line
   - In case of very big stack trace, there will be 2*x error lines
   - In such case I do not see any debug output

In this case, it's about recursion:

  File "b2.py", line 124, in seek_solution
    solution = self.seek_solution(weight + U.gravity, len(test), test)
  File "b2.py", line 124, in seek_solution
    solution = self.seek_solution(weight + U.gravity, len(test), test)
  File "b2.py", line 124, in seek_solution
    solution = self.seek_solution(weight + U.gravity, len(test), test)
  File "b2.py", line 124, in seek_solution
    solution = self.seek_solution(weight + U.gravity, len(test), test)
  File "b2.py", line 124, in seek_solution
    solution = self.seek_solution(weight + U.gravity, len(test), test)
  File "b2.py", line 124, in seek_solution
    solution = self.seek_solution(weight + U.gravity, len(test), test)
and so on...

I think it should be instead:
  File "b2.py", line 124, in seek_solution [*repeated x times*]
    solution = self.seek_solution(weight + U.gravity, len(test), test)

Getting big strack trace is most probable with functions calling themselves
- thus, long stack traces usually contain such repetitions.

As those functions might not call themselves directly, one cycle of
recursion might become four lines long, in such case:

Stack item 1:  File "b2.py", line 124, in seek_solution
    solution = self.seek_solution(weight + U.gravity, len(test), test)
Stack item 2:  File "b2.py", line 124, in seek_solution
    solution = self.seek_solution(weight + U.gravity, len(test), test)
Stack item repetitions: [#1, #2] * x

This could simply enumerate stack items and then create formulas of
repetitions, like:
[[#1, #2] * 15, #3 * 15] * 3

If it shows each message written-out at least one and max two or three
times, but over that gives it an id and shows patterns of those instead, it
will be a lot better. I have, sometimes, gone through some four pages of
Java stack traces etc., but I think that having such long array of errors
does not make it more readable or simple - if you can see everything in one
page, then it's good enough for pondering. And scrolling up and looking at
output would be a nice feature ;) Especially now, as I am going to raise
recursion limit - this program would be perfectly possible without relying
on built-in loop constructions so much, but I did it yesterday in such
manner and it simply raised into unmanageable complexity. Thus, now I am
trying to encapsulate it's logic into pieces, which maximize the use of
Pythons overloads and function-based iterators etc., but this makes error
messages that long when I do something wrong - and I can't even check if
that was really some mistake in code or just the recursion actually needs to
be deeper than I hoped.

Tambet
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100707/bcf14e21/attachment.html>


More information about the Python-list mailing list