diff options
author | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2018-09-14 08:00:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-14 08:00:11 (GMT) |
commit | 00bc08ec11d99cc68c7d5dc790ad3e609982a9c7 (patch) | |
tree | 784d23a8e87b5fc4057d3afd33782475b322e224 /Objects | |
parent | 902bcd9a1e2c73c6de5510b771c590b618c4c94e (diff) | |
download | cpython-00bc08ec11d99cc68c7d5dc790ad3e609982a9c7.zip cpython-00bc08ec11d99cc68c7d5dc790ad3e609982a9c7.tar.gz cpython-00bc08ec11d99cc68c7d5dc790ad3e609982a9c7.tar.bz2 |
Fix-up parenthesis, organization, and NULL check (GH-9297)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/longobject.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index 98ff9a8..102093e 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -5280,14 +5280,19 @@ static PyObject * int_as_integer_ratio_impl(PyObject *self) /*[clinic end generated code: output=e60803ae1cc8621a input=55ce3058e15de393]*/ { - if PyLong_CheckExact(self) { + PyObject *numerator; + PyObject *ratio_tuple; + + if (PyLong_CheckExact(self)) { return PyTuple_Pack(2, self, _PyLong_One); - } else { - PyObject *numerator = _PyLong_Copy(self); - PyObject *ratio_tuple = PyTuple_Pack(2, numerator, _PyLong_One); - Py_DECREF(numerator); - return ratio_tuple; } + numerator = _PyLong_Copy(self); + if (numerator == NULL) { + return NULL; + } + ratio_tuple = PyTuple_Pack(2, numerator, _PyLong_One); + Py_DECREF(numerator); + return ratio_tuple; } /*[clinic input] |