Issue 12276: 3.x ignores sys.tracebacklimit=0 (original) (raw)
Python 3.x doesn't honor sys.tracebacklimit=0
According to http://docs.python.org/py3k/library/sys.html#sys.tracebacklimit when set to 0, it should not print any stack trace, but it does.
Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information. p3> import sys p3> sys.tracebacklimit = 0 p3> p3> def f(x): ... return f(x-1) if x else 0/0 ... p3> f(5) Traceback (most recent call last): File "", line 1, in File "", line 2, in f File "", line 2, in f File "", line 2, in f File "", line 2, in f File "", line 2, in f File "", line 2, in f ZeroDivisionError: division by zero p3>
Is this the intended behavior then? I don't get the rationale for that change.
There is no way to completely supress traceback information now; for sys.tracebacklimit to be of any significance, it must be >= 1; 0 and negative values behave the same as it not being set (that is, a full traceback is printed).