]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Take out duplication of code in initmodule().
authorGuido van Rossum <guido@python.org>
Fri, 26 Oct 1990 14:59:30 +0000 (14:59 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 26 Oct 1990 14:59:30 +0000 (14:59 +0000)
Modules/mathmodule.c

index 400790f6b153d8a31f4cb490707c36a7deff1e15..93b24fc2a71f1cbb12abac899d6c5fe2ab2d8612 100644 (file)
@@ -150,18 +150,9 @@ void
 initmath()
 {
        object *m, *d, *v;
-       struct methodlist *ml;
-       if ((m = new_module("math")) == NULL)
-               fatal("can't create math module");
+       
+       m = initmodule("math", math_methods);
        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, "e", newfloatobject(exp(1.0)));
-       DECREF(m);
 }