From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id B8B2D38560AF; Thu, 23 Jun 2022 15:45:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B8B2D38560AF Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Use PyBool_FromLong X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 570e911f4e533fad33ad5e4e1102929cf7e80bd7 X-Git-Newrev: c86acd3f180419c3d9825170492363fe2322fa8d Message-Id: <20220623154525.B8B2D38560AF@sourceware.org> Date: Thu, 23 Jun 2022 15:45:25 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jun 2022 15:45:25 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dc86acd3f1804= 19c3d9825170492363fe2322fa8d commit c86acd3f180419c3d9825170492363fe2322fa8d Author: Tom Tromey Date: Tue Jun 7 09:15:24 2022 -0600 Use PyBool_FromLong =20 I noticed a few spots that were explicitly creating new references to Py_True or Py_False. It's simpler here to use PyBool_FromLong, so this patch changes all the places I found. Diff: --- gdb/python/py-cmd.c | 3 +-- gdb/python/py-symbol.c | 3 +-- gdb/python/py-type.c | 6 ++---- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c index f80318374d3..5cc392af175 100644 --- a/gdb/python/py-cmd.c +++ b/gdb/python/py-cmd.c @@ -128,8 +128,7 @@ cmdpy_function (const char *args, int from_tty, cmd_lis= t_element *command) error (_("Could not convert arguments to Python string.")); } =20 - gdbpy_ref<> ttyobj - =3D gdbpy_ref<>::new_reference (from_tty ? Py_True : Py_False); + gdbpy_ref<> ttyobj (PyBool_FromLong (from_tty)); gdbpy_ref<> result (PyObject_CallMethodObjArgs ((PyObject *) obj, invoke= _cst, argobj.get (), ttyobj.get (), NULL)); diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index 02c35acd1e9..23495b66d42 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -426,8 +426,7 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, Py= Object *kw) } PyTuple_SET_ITEM (ret_tuple.get (), 0, sym_obj); =20 - bool_obj =3D (is_a_field_of_this.type !=3D NULL) ? Py_True : Py_False; - Py_INCREF (bool_obj); + bool_obj =3D PyBool_FromLong (is_a_field_of_this.type !=3D NULL); PyTuple_SET_ITEM (ret_tuple.get (), 1, bool_obj); =20 return ret_tuple.release (); diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 5352ead84bd..0e772ad44b4 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -220,14 +220,12 @@ convert_field (struct type *type, int field) if (PyObject_SetAttrString (result.get (), "name", arg.get ()) < 0) return NULL; =20 - arg =3D gdbpy_ref<>::new_reference (TYPE_FIELD_ARTIFICIAL (type, field) - ? Py_True : Py_False); + arg.reset (PyBool_FromLong (TYPE_FIELD_ARTIFICIAL (type, field))); if (PyObject_SetAttrString (result.get (), "artificial", arg.get ()) < 0) return NULL; =20 if (type->code () =3D=3D TYPE_CODE_STRUCT) - arg =3D gdbpy_ref<>::new_reference (field < TYPE_N_BASECLASSES (type) - ? Py_True : Py_False); + arg.reset (PyBool_FromLong (field < TYPE_N_BASECLASSES (type))); else arg =3D gdbpy_ref<>::new_reference (Py_False); if (PyObject_SetAttrString (result.get (), "is_base_class", arg.get ()) = < 0)