Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 0/2] [gdb/python] Remove Py_RETURN_{NONE,TRUE,FALSE}
@ 2026-05-12 16:34 Tom de Vries
  2026-05-12 16:34 ` [PATCH 1/2] [gdb/python] Add init_py_immortals Tom de Vries
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Tom de Vries @ 2026-05-12 16:34 UTC (permalink / raw)
  To: gdb-patches

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-05-13 16:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-12 16:34 [PATCH 0/2] [gdb/python] Remove Py_RETURN_{NONE,TRUE,FALSE} Tom de Vries
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox