diff options
author | Guido van Rossum <guido@python.org> | 1993-12-17 12:09:14 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1993-12-17 12:09:14 (GMT) |
commit | 67a5fdbcc2d86cda9ee2efb7a97cb458036d6927 (patch) | |
tree | 2a23c03983e370fc5da75f547961f1e0ccc713cf /Python | |
parent | ad7324c71fbbb60eb34f7d6fe6b5c3663d114304 (diff) | |
download | cpython-67a5fdbcc2d86cda9ee2efb7a97cb458036d6927.zip cpython-67a5fdbcc2d86cda9ee2efb7a97cb458036d6927.tar.gz cpython-67a5fdbcc2d86cda9ee2efb7a97cb458036d6927.tar.bz2 |
* mpzmodule.c: cast some methods to the proper type.
* traceback.c (tb_print): use sys.tracebacklimit as a maximum number of
traceback entries to print (default 1000).
* ceval.c (printtraceback): Don't print stack trace header -- this is now
done by tb_print().
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 1 | ||||
-rw-r--r-- | Python/traceback.c | 28 |
2 files changed, 23 insertions, 6 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 425e2a0..6ffbb46 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1710,7 +1710,6 @@ printtraceback(f) { object *v = tb_fetch(); if (v != NULL) { - writestring("Stack backtrace (innermost last):\n", f); tb_print(v, f); DECREF(v); } diff --git a/Python/traceback.c b/Python/traceback.c index 6ed1917..f14f0ec 100644 --- a/Python/traceback.c +++ b/Python/traceback.c @@ -219,14 +219,23 @@ tb_displayline(f, filename, lineno) } static void -tb_printinternal(tb, f) +tb_printinternal(tb, f, limit) tracebackobject *tb; object *f; + int limit; { + int depth = 0; + tracebackobject *tb1 = tb; + while (tb1 != NULL) { + depth++; + tb1 = tb1->tb_next; + } while (tb != NULL && !intrcheck()) { - tb_displayline(f, - getstringvalue(tb->tb_frame->f_code->co_filename), - tb->tb_lineno); + if (depth <= limit) + tb_displayline(f, + getstringvalue(tb->tb_frame->f_code->co_filename), + tb->tb_lineno); + depth--; tb = tb->tb_next; } } @@ -236,6 +245,8 @@ tb_print(v, f) object *v; object *f; { + object *limitv; + int limit = 1000; if (v == NULL) return 0; if (!is_tracebackobject(v)) { @@ -243,6 +254,13 @@ tb_print(v, f) return -1; } sysset("last_traceback", v); - tb_printinternal((tracebackobject *)v, f); + limitv = sysget("tracebacklimit"); + if (limitv && is_intobject(limitv)) { + limit = getintvalue(limitv); + if (limit <= 0) + return 0; + } + writestring("Traceback (innermost last):\n", f); + tb_printinternal((tracebackobject *)v, f, limit); return 0; } |