summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1990-10-26 14:59:30 (GMT)
committerGuido van Rossum <guido@python.org>1990-10-26 14:59:30 (GMT)
commit738d4ddf813d88de6d1c3c1c225857215fe7c13d (patch)
tree181ccf84c212778cafe9c11f1d83ca17370e5e59 /Modules
parented97f6aa041b576a9b05aefa3e5ff9de6cdb8d98 (diff)
downloadcpython-738d4ddf813d88de6d1c3c1c225857215fe7c13d.zip
cpython-738d4ddf813d88de6d1c3c1c225857215fe7c13d.tar.gz
cpython-738d4ddf813d88de6d1c3c1c225857215fe7c13d.tar.bz2
Take out duplication of code in initmodule().
Diffstat (limited to 'Modules')
-rw-r--r--Modules/mathmodule.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
index 400790f..93b24fc 100644
--- a/Modules/mathmodule.c
+++ b/Modules/mathmodule.c
@@ -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);
}