Take out duplication of code in initmodule().

This commit is contained in:
Guido van Rossum 1990-10-26 14:59:30 +00:00
parent ed97f6aa04
commit 738d4ddf81
1 changed files with 2 additions and 11 deletions

View File

@ -150,18 +150,9 @@ void
initmath() initmath()
{ {
object *m, *d, *v; object *m, *d, *v;
struct methodlist *ml;
if ((m = new_module("math")) == NULL) m = initmodule("math", math_methods);
fatal("can't create math module");
d = getmoduledict(m); d = getmoduledict(m);
for (ml = math_methods; ml->ml_name != NULL; ml++) {
v = newmethodobject(ml->ml_name, ml->ml_meth, (object *)NULL);
if (v == NULL || dictinsert(d, ml->ml_name, v) != 0) {
fatal("can't initialize math module");
}
DECREF(v);
}
dictinsert(d, "pi", newfloatobject(atan(1.0) * 4.0)); dictinsert(d, "pi", newfloatobject(atan(1.0) * 4.0));
dictinsert(d, "e", newfloatobject(exp(1.0))); dictinsert(d, "e", newfloatobject(exp(1.0)));
DECREF(m);
} }