]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix-up parenthesis, organization, and NULL check (GH-9297)
authorRaymond Hettinger <rhettinger@users.noreply.github.com>
Fri, 14 Sep 2018 08:00:11 +0000 (01:00 -0700)
committerGitHub <noreply@github.com>
Fri, 14 Sep 2018 08:00:11 +0000 (01:00 -0700)
Objects/longobject.c

index 98ff9a8c265bc547ee60a748752c2d234ffc041d..102093e1986547baa1f4ba3e5de0a0a0fc6596a3 100644 (file)
@@ -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]