File tree 1 file changed +9
-5
lines changed 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -1125,8 +1125,13 @@ static PyObject *
1125
1125
math_ceil (PyObject * module , PyObject * number )
1126
1126
/*[clinic end generated code: output=6c3b8a78bc201c67 input=2725352806399cab]*/
1127
1127
{
1128
+ double x ;
1128
1129
1129
- if (!PyFloat_CheckExact (number )) {
1130
+ if (PyFloat_CheckExact (number )) {
1131
+ x = PyFloat_AS_DOUBLE (number );
1132
+ }
1133
+ else
1134
+ {
1130
1135
math_module_state * state = get_math_module_state (module );
1131
1136
PyObject * method = _PyObject_LookupSpecial (number , state -> str___ceil__ );
1132
1137
if (method != NULL ) {
@@ -1136,11 +1141,10 @@ math_ceil(PyObject *module, PyObject *number)
1136
1141
}
1137
1142
if (PyErr_Occurred ())
1138
1143
return NULL ;
1144
+ x = PyFloat_AsDouble (number );
1145
+ if (x == -1.0 && PyErr_Occurred ())
1146
+ return NULL ;
1139
1147
}
1140
- double x = PyFloat_AsDouble (number );
1141
- if (x == -1.0 && PyErr_Occurred ())
1142
- return NULL ;
1143
-
1144
1148
return PyLong_FromDouble (ceil (x ));
1145
1149
}
1146
1150
You can’t perform that action at this time.
0 commit comments