Skip to content

Commit 00bc08e

Browse files
authored
Fix-up parenthesis, organization, and NULL check (GH-9297)
1 parent 902bcd9 commit 00bc08e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Objects/longobject.c

+11-6
Original file line numberDiff line numberDiff line change
@@ -5280,14 +5280,19 @@ static PyObject *
52805280
int_as_integer_ratio_impl(PyObject *self)
52815281
/*[clinic end generated code: output=e60803ae1cc8621a input=55ce3058e15de393]*/
52825282
{
5283-
if PyLong_CheckExact(self) {
5283+
PyObject *numerator;
5284+
PyObject *ratio_tuple;
5285+
5286+
if (PyLong_CheckExact(self)) {
52845287
return PyTuple_Pack(2, self, _PyLong_One);
5285-
} else {
5286-
PyObject *numerator = _PyLong_Copy(self);
5287-
PyObject *ratio_tuple = PyTuple_Pack(2, numerator, _PyLong_One);
5288-
Py_DECREF(numerator);
5289-
return ratio_tuple;
52905288
}
5289+
numerator = _PyLong_Copy(self);
5290+
if (numerator == NULL) {
5291+
return NULL;
5292+
}
5293+
ratio_tuple = PyTuple_Pack(2, numerator, _PyLong_One);
5294+
Py_DECREF(numerator);
5295+
return ratio_tuple;
52915296
}
52925297

52935298
/*[clinic input]

0 commit comments

Comments
 (0)