File tree 1 file changed +10
-5
lines changed
1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -1256,9 +1256,15 @@ static PyObject *
1256
1256
math_floor (PyObject * module , PyObject * number )
1257
1257
/*[clinic end generated code: output=c6a65c4884884b8a input=63af6b5d7ebcc3d6]*/
1258
1258
{
1259
+ double x ;
1260
+
1259
1261
_Py_IDENTIFIER (__floor__ );
1260
1262
1261
- if (!PyFloat_CheckExact (number )) {
1263
+ if (PyFloat_CheckExact (number )) {
1264
+ x = PyFloat_AS_DOUBLE (number );
1265
+ }
1266
+ else
1267
+ {
1262
1268
PyObject * method = _PyObject_LookupSpecial (number , & PyId___floor__ );
1263
1269
if (method != NULL ) {
1264
1270
PyObject * result = _PyObject_CallNoArg (method );
@@ -1267,11 +1273,10 @@ math_floor(PyObject *module, PyObject *number)
1267
1273
}
1268
1274
if (PyErr_Occurred ())
1269
1275
return NULL ;
1276
+ x = PyFloat_AsDouble (number );
1277
+ if (x == -1.0 && PyErr_Occurred ())
1278
+ return NULL ;
1270
1279
}
1271
- double x = PyFloat_AsDouble (number );
1272
- if (x == -1.0 && PyErr_Occurred ())
1273
- return NULL ;
1274
-
1275
1280
return PyLong_FromDouble (floor (x ));
1276
1281
}
1277
1282
You can’t perform that action at this time.
0 commit comments