err_setstr(TypeError, "number coercion (to mpzobject) failed");
return NULL;
} /* mpz_mpzcoerce() */
-
+
+static void mpz_divm();
+
static object *
MPZ_powm(self, args)
object *self;
} /* MPZ_sqrtrem() */
-void
+static void
#if __STDC__
mpz_divm(MP_INT *res, const MP_INT *num, const MP_INT *den, const MP_INT *mod)
#else
{"hex", mpz_hex},
{"oct", mpz_oct},
#endif /* def MPZ_CONVERSIONS_AS_METHODS */
- {"binary", mpz_binary},
+ {"binary", (object * (*) (object *, object *)) mpz_binary},
{NULL, NULL} /* sentinel */
};
sizeof(mpzobject), /*tp_size*/
0, /*tp_itemsize*/
/* methods */
- mpz_dealloc, /*tp_dealloc*/
+ (void (*) (object *)) mpz_dealloc, /*tp_dealloc*/
0, /*tp_print*/
- mpz_getattr, /*tp_getattr*/
+ (object * (*)(object *, char *)) mpz_getattr, /*tp_getattr*/
0, /*tp_setattr*/
- mpz_compare, /*tp_compare*/
+ (int (*) (object *, object *)) mpz_compare, /*tp_compare*/
mpz_repr, /*tp_repr*/
&mpz_as_number, /*tp_as_number*/
};
}
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;
}
}
object *v;
object *f;
{
+ object *limitv;
+ int limit = 1000;
if (v == NULL)
return 0;
if (!is_tracebackobject(v)) {
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;
}