[issue46949] Print an indication if traceback exceeds sys.tracebacklimit

2022-03-07 Thread Irit Katriel

Irit Katriel  added the comment:

Re what the limit means, it’s a bit messier than that, see issue38197.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46949] Print an indication if traceback exceeds sys.tracebacklimit

2022-03-07 Thread Eric V. Smith


Eric V. Smith  added the comment:

If you go with the second idea, I'd say something like f"More than {2 * 
tracebacklimit} additional stack frames not shown". It seems handy to know the 
magnitude of the problem.

--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46949] Print an indication if traceback exceeds sys.tracebacklimit

2022-03-07 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

It skips the least recent frames:

>>> def error(): 1 / 0
... 
>>> def g(): error()
... 
>>> def f(): g()
... 
>>> sys.tracebacklimit = 2
>>> f()
Traceback (most recent call last):
  File "", line 1, in g
  File "", line 1, in error
ZeroDivisionError: division by zero
>>> sys.tracebacklimit = 5
>>> f()
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 1, in f
  File "", line 1, in g
  File "", line 1, in error
ZeroDivisionError: division by zero

(tried on current main)

I think that's the right behavior because it tells you the function that 
actually throws the error, which is much harder to figure out from scratch than 
where the call started.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46949] Print an indication if traceback exceeds sys.tracebacklimit

2022-03-07 Thread Guido van Rossum


Guido van Rossum  added the comment:

There is general confusion as to which part of the traceback is truncated. If I 
have main() -> f() -> g() -> error(), and the limit is 2, does it print main() 
-> f(), or does it print g() -> error()? (I'm not even sure which would be more 
useful.)

FWIW the reason I suggested printing "many" is a worry that somehow a bug could 
cause counting the length of the list to take forever (e.g. if it ends in a 
cycle). It would seem more robust to limit the count.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46949] Print an indication if traceback exceeds sys.tracebacklimit

2022-03-07 Thread Jelle Zijlstra


New submission from Jelle Zijlstra :

If the number of frames in a traceback exceeds sys.tracebacklimit (which 
defaults to 1000), any remaining frames are silently dropped. See 
https://docs.python.org/3.10/library/sys.html#sys.tracebacklimit.

This is confusing to users. We should print some indication like "N additional 
stack frames not shown".

Here are some specific ideas:
- tracebacklimit <= 0 is documented as dropping the whole traceback. In that 
case, we don't need too print any message.
- It may be expensive to compute a complete count. Perhaps we can count frames 
up to 2 * tracebacklimit, and just say "Many additional stack frames not shown".
- The C implementation is in tb_print_internal() in traceback.c, and the Python 
one in _extract_from_extended_frame_gen in traceback.py.

--
components: Interpreter Core
messages: 414674
nosy: Jelle Zijlstra, gvanrossum, iritkatriel
priority: normal
severity: normal
status: open
title: Print an indication if traceback exceeds sys.tracebacklimit
type: enhancement
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com