mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
fix lookup of __ceil__
This commit is contained in:
parent
b0125892e6
commit
f751bc9c01
3 changed files with 12 additions and 11 deletions
|
@ -1581,6 +1581,7 @@ order (MRO) for bases """
|
||||||
("__format__", format, format_impl, set(), {}),
|
("__format__", format, format_impl, set(), {}),
|
||||||
("__floor__", math.floor, zero, set(), {}),
|
("__floor__", math.floor, zero, set(), {}),
|
||||||
("__trunc__", math.trunc, zero, set(), {}),
|
("__trunc__", math.trunc, zero, set(), {}),
|
||||||
|
("__ceil__", math.ceil, zero, set(), {}),
|
||||||
]
|
]
|
||||||
|
|
||||||
class Checker(object):
|
class Checker(object):
|
||||||
|
|
|
@ -1374,8 +1374,8 @@ Library
|
||||||
Extension Modules
|
Extension Modules
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
- In the math module, correctly lookup __trunc__ and __floor__ as special
|
- In the math module, correctly lookup __trunc__, __ceil__, and __floor__ as
|
||||||
methods.
|
special methods.
|
||||||
|
|
||||||
- Issue #9005: Prevent utctimetuple() from producing year 0 or year
|
- Issue #9005: Prevent utctimetuple() from producing year 0 or year
|
||||||
10,000. Prior to this change, timezone adjustment in utctimetuple()
|
10,000. Prior to this change, timezone adjustment in utctimetuple()
|
||||||
|
|
|
@ -843,17 +843,17 @@ static PyObject * math_ceil(PyObject *self, PyObject *number) {
|
||||||
static PyObject *ceil_str = NULL;
|
static PyObject *ceil_str = NULL;
|
||||||
PyObject *method;
|
PyObject *method;
|
||||||
|
|
||||||
if (ceil_str == NULL) {
|
method = _PyObject_LookupSpecial(number, "__ceil__", &ceil_str);
|
||||||
ceil_str = PyUnicode_InternFromString("__ceil__");
|
if (method == NULL) {
|
||||||
if (ceil_str == NULL)
|
if (PyErr_Occurred())
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
method = _PyType_Lookup(Py_TYPE(number), ceil_str);
|
|
||||||
if (method == NULL)
|
|
||||||
return math_1_to_int(number, ceil, 0);
|
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,
|
PyDoc_STRVAR(math_ceil_doc,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue