summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1996-12-17 00:47:03 (GMT)
committerBarry Warsaw <barry@python.org>1996-12-17 00:47:03 (GMT)
commitfc93f75da75e430a20b37f2a73dacfa94d8a9758 (patch)
tree0c7159c8bdbde241d53eeadc852813eed2b5544b
parentd0c1042ff23c2479c79c7d190e4a03ca28a24c34 (diff)
downloadcpython-fc93f75da75e430a20b37f2a73dacfa94d8a9758.zip
cpython-fc93f75da75e430a20b37f2a73dacfa94d8a9758.tar.gz
cpython-fc93f75da75e430a20b37f2a73dacfa94d8a9758.tar.bz2
Better error checking in initmath().
-rw-r--r--Modules/mathmodule.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
index 6e2d65b..b993bfc 100644
--- a/Modules/mathmodule.c
+++ b/Modules/mathmodule.c
@@ -242,8 +242,19 @@ initmath()
m = Py_InitModule("math", math_methods);
d = PyModule_GetDict(m);
- PyDict_SetItemString(d, "pi", v = PyFloat_FromDouble(atan(1.0) * 4.0));
+
+ if (!(v = PyFloat_FromDouble(atan(1.0) * 4.0)))
+ goto finally;
+ if (PyDict_SetItemString(d, "pi", v) < 0)
+ goto finally;
Py_DECREF(v);
- PyDict_SetItemString(d, "e", v = PyFloat_FromDouble(exp(1.0)));
+
+ if (!(v = PyFloat_FromDouble(exp(1.0))))
+ goto finally;
+ if (PyDict_SetItemString(d, "e", ) < 0)
+ goto finally;
Py_DECREF(v);
+
+ finally:
+ Py_FatalError("can't initialize math module");
}