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