Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 0/2] [gdb/python] Remove Py_RETURN_{NONE,TRUE,FALSE}
Date: Tue, 12 May 2026 18:34:36 +0200	[thread overview]
Message-ID: <20260512163438.2446764-1-tdevries@suse.de> (raw)

I came across this code:
...
   if (c)
     return v;
   else
     Py_RETURN_NONE;
...
and realized I couldn't easily rewrite it into "return c ? v : ...".

Probably something like this would work:
...
  return c ? v : ([] { Py_RETURN_NONE; } ());
...
but it made me wonder if we can rid of Py_RETURN_NONE.

The only point of it seems to be to increase the reference count on the
Py_None object for older python versions.

ISTM unnecessary to increase the reference count for each Py_RETURN_NONE use.

Instead, increase the reference count of Py_None once, and use a simple
"return Py_None" instead of Py_RETURN_NONE everywhere.

Tom de Vries (2):
  [gdb/python] Add init_py_immortals
  [gdb/python] Remove Py_RETURN_{NONE,TRUE,FALSE}

 gdb/python/py-block.c            | 22 ++++++-------
 gdb/python/py-breakpoint.c       | 54 ++++++++++++++++----------------
 gdb/python/py-cmd.c              |  2 +-
 gdb/python/py-connection.c       |  6 ++--
 gdb/python/py-corefile.c         |  8 ++---
 gdb/python/py-disasm.c           |  6 ++--
 gdb/python/py-evtregistry.c      |  6 ++--
 gdb/python/py-finishbreakpoint.c |  2 +-
 gdb/python/py-frame.c            | 14 ++++-----
 gdb/python/py-framefilter.c      |  2 +-
 gdb/python/py-inferior.c         | 26 +++++++--------
 gdb/python/py-infthread.c        | 24 +++++++-------
 gdb/python/py-linetable.c        | 14 ++++-----
 gdb/python/py-mi.c               |  2 +-
 gdb/python/py-micmd.c            |  4 +--
 gdb/python/py-objfile.c          | 22 ++++++-------
 gdb/python/py-prettyprint.c      |  2 +-
 gdb/python/py-progspace.c        | 18 +++++------
 gdb/python/py-record-btrace.c    | 48 ++++++++++++++--------------
 gdb/python/py-record.c           | 12 +++----
 gdb/python/py-registers.c        |  2 +-
 gdb/python/py-symbol.c           | 10 +++---
 gdb/python/py-symtab.c           | 18 +++++------
 gdb/python/py-tui.c              | 10 +++---
 gdb/python/py-type.c             | 36 ++++++++++-----------
 gdb/python/py-unwind.c           | 12 +++----
 gdb/python/py-value.c            | 28 ++++++++---------
 gdb/python/py-xmethods.c         |  2 +-
 gdb/python/python.c              | 49 ++++++++++++++++++++---------
 29 files changed, 241 insertions(+), 220 deletions(-)


base-commit: 2d7f2dbbd4adadf7c388fa0d8b9ce95d9dfde641
-- 
2.51.0


             reply	other threads:[~2026-05-12 16:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12 16:34 Tom de Vries [this message]
2026-05-12 16:34 ` [PATCH 1/2] [gdb/python] Add init_py_immortals Tom de Vries
2026-05-12 16:34 ` [PATCH 2/2] [gdb/python] Remove Py_RETURN_{NONE,TRUE,FALSE} Tom de Vries
2026-05-13 14:44 ` [PATCH 0/2] " Tom Tromey
2026-05-13 16:42   ` Tom de Vries

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260512163438.2446764-1-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox