* 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().
This commit is contained in:
parent
ad7324c71f
commit
67a5fdbcc2
@ -993,7 +993,9 @@ mpz_mpzcoerce(z)
|
|||||||
err_setstr(TypeError, "number coercion (to mpzobject) failed");
|
err_setstr(TypeError, "number coercion (to mpzobject) failed");
|
||||||
return NULL;
|
return NULL;
|
||||||
} /* mpz_mpzcoerce() */
|
} /* mpz_mpzcoerce() */
|
||||||
|
|
||||||
|
static void mpz_divm();
|
||||||
|
|
||||||
static object *
|
static object *
|
||||||
MPZ_powm(self, args)
|
MPZ_powm(self, args)
|
||||||
object *self;
|
object *self;
|
||||||
@ -1181,7 +1183,7 @@ MPZ_sqrtrem(self, args)
|
|||||||
} /* MPZ_sqrtrem() */
|
} /* MPZ_sqrtrem() */
|
||||||
|
|
||||||
|
|
||||||
void
|
static void
|
||||||
#if __STDC__
|
#if __STDC__
|
||||||
mpz_divm(MP_INT *res, const MP_INT *num, const MP_INT *den, const MP_INT *mod)
|
mpz_divm(MP_INT *res, const MP_INT *num, const MP_INT *den, const MP_INT *mod)
|
||||||
#else
|
#else
|
||||||
@ -1544,7 +1546,7 @@ static struct methodlist mpz_methods[] = {
|
|||||||
{"hex", mpz_hex},
|
{"hex", mpz_hex},
|
||||||
{"oct", mpz_oct},
|
{"oct", mpz_oct},
|
||||||
#endif /* def MPZ_CONVERSIONS_AS_METHODS */
|
#endif /* def MPZ_CONVERSIONS_AS_METHODS */
|
||||||
{"binary", mpz_binary},
|
{"binary", (object * (*) (object *, object *)) mpz_binary},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1639,11 +1641,11 @@ static typeobject MPZtype = {
|
|||||||
sizeof(mpzobject), /*tp_size*/
|
sizeof(mpzobject), /*tp_size*/
|
||||||
0, /*tp_itemsize*/
|
0, /*tp_itemsize*/
|
||||||
/* methods */
|
/* methods */
|
||||||
mpz_dealloc, /*tp_dealloc*/
|
(void (*) (object *)) mpz_dealloc, /*tp_dealloc*/
|
||||||
0, /*tp_print*/
|
0, /*tp_print*/
|
||||||
mpz_getattr, /*tp_getattr*/
|
(object * (*)(object *, char *)) mpz_getattr, /*tp_getattr*/
|
||||||
0, /*tp_setattr*/
|
0, /*tp_setattr*/
|
||||||
mpz_compare, /*tp_compare*/
|
(int (*) (object *, object *)) mpz_compare, /*tp_compare*/
|
||||||
mpz_repr, /*tp_repr*/
|
mpz_repr, /*tp_repr*/
|
||||||
&mpz_as_number, /*tp_as_number*/
|
&mpz_as_number, /*tp_as_number*/
|
||||||
};
|
};
|
||||||
|
@ -1710,7 +1710,6 @@ printtraceback(f)
|
|||||||
{
|
{
|
||||||
object *v = tb_fetch();
|
object *v = tb_fetch();
|
||||||
if (v != NULL) {
|
if (v != NULL) {
|
||||||
writestring("Stack backtrace (innermost last):\n", f);
|
|
||||||
tb_print(v, f);
|
tb_print(v, f);
|
||||||
DECREF(v);
|
DECREF(v);
|
||||||
}
|
}
|
||||||
|
@ -219,14 +219,23 @@ tb_displayline(f, filename, lineno)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tb_printinternal(tb, f)
|
tb_printinternal(tb, f, limit)
|
||||||
tracebackobject *tb;
|
tracebackobject *tb;
|
||||||
object *f;
|
object *f;
|
||||||
|
int limit;
|
||||||
{
|
{
|
||||||
|
int depth = 0;
|
||||||
|
tracebackobject *tb1 = tb;
|
||||||
|
while (tb1 != NULL) {
|
||||||
|
depth++;
|
||||||
|
tb1 = tb1->tb_next;
|
||||||
|
}
|
||||||
while (tb != NULL && !intrcheck()) {
|
while (tb != NULL && !intrcheck()) {
|
||||||
tb_displayline(f,
|
if (depth <= limit)
|
||||||
getstringvalue(tb->tb_frame->f_code->co_filename),
|
tb_displayline(f,
|
||||||
tb->tb_lineno);
|
getstringvalue(tb->tb_frame->f_code->co_filename),
|
||||||
|
tb->tb_lineno);
|
||||||
|
depth--;
|
||||||
tb = tb->tb_next;
|
tb = tb->tb_next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -236,6 +245,8 @@ tb_print(v, f)
|
|||||||
object *v;
|
object *v;
|
||||||
object *f;
|
object *f;
|
||||||
{
|
{
|
||||||
|
object *limitv;
|
||||||
|
int limit = 1000;
|
||||||
if (v == NULL)
|
if (v == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
if (!is_tracebackobject(v)) {
|
if (!is_tracebackobject(v)) {
|
||||||
@ -243,6 +254,13 @@ tb_print(v, f)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sysset("last_traceback", v);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user