]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-111417: Remove unused code block in math.trunc() and round() (GH-111454)
authorJason Zhang <yurenzhang2017@gmail.com>
Sat, 3 Feb 2024 15:11:10 +0000 (15:11 +0000)
committerGitHub <noreply@github.com>
Sat, 3 Feb 2024 15:11:10 +0000 (17:11 +0200)
_PyObject_LookupSpecial() now ensures that the type is ready.

Modules/mathmodule.c
Python/bltinmodule.c

index 0be46b1574c1feb6dee86fb436c771d3bbff0027..a877bfcd6afb6872334d69e2f3f09735f5485cab 100644 (file)
@@ -2074,11 +2074,6 @@ math_trunc(PyObject *module, PyObject *x)
         return PyFloat_Type.tp_as_number->nb_int(x);
     }
 
-    if (!_PyType_IsReady(Py_TYPE(x))) {
-        if (PyType_Ready(Py_TYPE(x)) < 0)
-            return NULL;
-    }
-
     math_module_state *state = get_math_module_state(module);
     trunc = _PyObject_LookupSpecial(x, state->str___trunc__);
     if (trunc == NULL) {
index e54d5cbacdc96f93c940ec3e78b37f8457a5a845..31c1bf07e8fb913f9b735c7e3f8241e0e180bb0b 100644 (file)
@@ -2382,11 +2382,6 @@ builtin_round_impl(PyObject *module, PyObject *number, PyObject *ndigits)
 {
     PyObject *round, *result;
 
-    if (!_PyType_IsReady(Py_TYPE(number))) {
-        if (PyType_Ready(Py_TYPE(number)) < 0)
-            return NULL;
-    }
-
     round = _PyObject_LookupSpecial(number, &_Py_ID(__round__));
     if (round == NULL) {
         if (!PyErr_Occurred())