summaryrefslogtreecommitdiffstats
path: root/Modules/mathmodule.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-07-02 13:46:42 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-07-02 13:46:42 (GMT)
commitf751bc9c01b8c5c3dd99e188b348a63eb0b893af (patch)
treefb35226a63bd584d10922eb220241b7dd4b5f5d0 /Modules/mathmodule.c
parentb0125892e6fcdbb2c726322e702e5513ac42ba39 (diff)
downloadcpython-f751bc9c01b8c5c3dd99e188b348a63eb0b893af.zip
cpython-f751bc9c01b8c5c3dd99e188b348a63eb0b893af.tar.gz
cpython-f751bc9c01b8c5c3dd99e188b348a63eb0b893af.tar.bz2
fix lookup of __ceil__
Diffstat (limited to 'Modules/mathmodule.c')
-rw-r--r--Modules/mathmodule.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
index 64738f0..9141805 100644
--- a/Modules/mathmodule.c
+++ b/Modules/mathmodule.c
@@ -843,17 +843,17 @@ static PyObject * math_ceil(PyObject *self, PyObject *number) {
static PyObject *ceil_str = NULL;
PyObject *method;
- if (ceil_str == NULL) {
- ceil_str = PyUnicode_InternFromString("__ceil__");
- if (ceil_str == NULL)
+ method = _PyObject_LookupSpecial(number, "__ceil__", &ceil_str);
+ if (method == NULL) {
+ if (PyErr_Occurred())
return NULL;
- }
-
- method = _PyType_Lookup(Py_TYPE(number), ceil_str);
- if (method == NULL)
return math_1_to_int(number, ceil, 0);
- else
- return PyObject_CallFunction(method, "O", number);
+ }
+ else {
+ PyObject *result = PyObject_CallFunctionObjArgs(method, NULL);
+ Py_DECREF(method);
+ return result;
+ }
}
PyDoc_STRVAR(math_ceil_doc,