File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -1255,9 +1255,15 @@ static PyObject *
12551255math_floor (PyObject * module , PyObject * number )
12561256/*[clinic end generated code: output=c6a65c4884884b8a input=63af6b5d7ebcc3d6]*/
12571257{
1258+ double x ;
1259+
12581260 _Py_IDENTIFIER (__floor__ );
12591261
1260- if (!PyFloat_CheckExact (number )) {
1262+ if (PyFloat_CheckExact (number )) {
1263+ x = PyFloat_AS_DOUBLE (number );
1264+ }
1265+ else
1266+ {
12611267 PyObject * method = _PyObject_LookupSpecial (number , & PyId___floor__ );
12621268 if (method != NULL ) {
12631269 PyObject * result = _PyObject_CallNoArg (method );
@@ -1266,11 +1272,10 @@ math_floor(PyObject *module, PyObject *number)
12661272 }
12671273 if (PyErr_Occurred ())
12681274 return NULL ;
1275+ x = PyFloat_AsDouble (number );
1276+ if (x == -1.0 && PyErr_Occurred ())
1277+ return NULL ;
12691278 }
1270- double x = PyFloat_AsDouble (number );
1271- if (x == -1.0 && PyErr_Occurred ())
1272- return NULL ;
1273-
12741279 return PyLong_FromDouble (floor (x ));
12751280}
12761281
You can’t perform that action at this time.
0 commit comments