Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH v2 0/2] [gdb/python] Remove Py_RETURN_{NONE,TRUE,FALSE}
@ 2026-05-13 16:30 Tom de Vries
  2026-05-13 16:30 ` [PATCH v2 1/2] [gdb/python] Introduce py_none/py_true/py_false functions Tom de Vries
  2026-05-13 16:30 ` [PATCH v2 2/2] [gdb/python] Remove Py_RETURN_{NONE,TRUE,FALSE} Tom de Vries
  0 siblings, 2 replies; 6+ messages in thread
From: Tom de Vries @ 2026-05-13 16:30 UTC (permalink / raw)
  To: gdb-patches

This patch series contains two patches.

The first introduces refcount-safe wrapper functions py_none, py_true and
py_false.

The second uses those functions instead of Py_RETURN_{NONE,TRUE,FALSE}.

Tested on x86_64-linux, with python versions 3.13.13 and 3.6.15.

Changes in v2:
- changed approach.  The approach taken in v1 was incorrect, and caused
  regressions with pre 3.12 python versions, as pointed out by Tom Tromey in a
  PR review comment.

Versions:
- v1: https://sourceware.org/pipermail/gdb-patches/2026-May/227344.html

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34145

Tom de Vries (2):
  [gdb/python] Introduce py_none/py_true/py_false functions
  [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-internal.h     | 23 ++++++++++++++
 gdb/python/python.c              | 28 ++++++++---------
 30 files changed, 243 insertions(+), 220 deletions(-)


base-commit: 9e95e538bc7ba805e2eb2b567edb675f12097694
-- 
2.51.0


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

* [PATCH v2 1/2] [gdb/python] Introduce py_none/py_true/py_false functions
  2026-05-13 16:30 [PATCH v2 0/2] [gdb/python] Remove Py_RETURN_{NONE,TRUE,FALSE} Tom de Vries
@ 2026-05-13 16:30 ` Tom de Vries
  2026-05-14 17:46   ` Tom Tromey
  2026-05-13 16:30 ` [PATCH v2 2/2] [gdb/python] Remove Py_RETURN_{NONE,TRUE,FALSE} Tom de Vries
  1 sibling, 1 reply; 6+ messages in thread
From: Tom de Vries @ 2026-05-13 16:30 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.

Add a refcount-safe wrapper py_none (returning a gdbpy_ref), with the aim of
replacing all uses of Py_RETURN_NONE with "return py_none ().release ()".

Likewise for Py_RETURN_TRUE/Py_RETURN_FALSE.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34145
---
 gdb/python/python-internal.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index 37bc37691fe..c3c1f0e6a6f 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -1340,4 +1340,27 @@ class gdbpy_memoizing_registry_storage
 extern int eval_python_command (const char *command, int start_symbol,
 				const char *filename = nullptr);
 
+/* The following three functions are refcount-safe wrappers around
+   Py_RETURN_{NONE,TRUE,FALSE}.  Starting with python 3.12, None, True and
+   False are immortal, and increasing and decreasing refcount for such object
+   is a no-op, but while supporting older versions we ignore that aspect
+   here.  */
+
+static inline gdbpy_ref<>
+py_none ()
+{
+  return gdbpy_ref<> ([] { Py_RETURN_NONE; } ());
+}
+
+static inline gdbpy_ref<>
+py_true ()
+{
+  return gdbpy_ref<> ([] { Py_RETURN_TRUE; } ());
+}
+
+static inline gdbpy_ref<>
+py_false ()
+{
+  return gdbpy_ref<> ([] { Py_RETURN_FALSE; } ());
+}
 #endif /* GDB_PYTHON_PYTHON_INTERNAL_H */
-- 
2.51.0


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

* [PATCH v2 2/2] [gdb/python] Remove Py_RETURN_{NONE,TRUE,FALSE}
  2026-05-13 16:30 [PATCH v2 0/2] [gdb/python] Remove Py_RETURN_{NONE,TRUE,FALSE} Tom de Vries
  2026-05-13 16:30 ` [PATCH v2 1/2] [gdb/python] Introduce py_none/py_true/py_false functions Tom de Vries
@ 2026-05-13 16:30 ` Tom de Vries
  2026-05-14 17:47   ` Tom Tromey
  1 sibling, 1 reply; 6+ messages in thread
From: Tom de Vries @ 2026-05-13 16:30 UTC (permalink / raw)
  To: gdb-patches

Result of:
...
$ sed -i 's/Py_RETURN_NONE/return py_none ().release ()/' gdb/python/*.{c,h}
...
with the changes in py_none reverted.

Likewise for Py_RETURN_TRUE and Py_RETURN_FALSE.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34145
---
 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              | 28 ++++++++---------
 29 files changed, 220 insertions(+), 220 deletions(-)

diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c
index d9751d26378..17c9cbdaff0 100644
--- a/gdb/python/py-block.c
+++ b/gdb/python/py-block.c
@@ -166,7 +166,7 @@ blpy_get_function (PyObject *self, void *closure)
   if (sym)
     return symbol_to_symbol_object (sym).release ();
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 static PyObject *
@@ -182,7 +182,7 @@ blpy_get_superblock (PyObject *self, void *closure)
   if (super_block)
     return block_to_block_object (super_block, self_obj->objfile).release ();
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Implement gdb.Block.subblocks attribute.  Return a list of gdb.Block
@@ -245,7 +245,7 @@ blpy_get_static_block (PyObject *self, void *closure)
   BLPY_REQUIRE_VALID (self, block);
 
   if (block->superblock () == NULL)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   static_block = block->static_block ();
 
@@ -263,9 +263,9 @@ blpy_is_global (PyObject *self, void *closure)
   BLPY_REQUIRE_VALID (self, block);
 
   if (block->superblock ())
-    Py_RETURN_FALSE;
+    return py_false ().release ();
 
-  Py_RETURN_TRUE;
+  return py_true ().release ();
 }
 
 /* Implementation of gdb.Block.is_static (self) -> Boolean.
@@ -280,9 +280,9 @@ blpy_is_static (PyObject *self, void *closure)
 
   if (block->superblock () != NULL
      && block->superblock ()->superblock () == NULL)
-    Py_RETURN_TRUE;
+    return py_true ().release ();
 
-  Py_RETURN_FALSE;
+  return py_false ().release ();
 }
 
 /* Given a string, returns the gdb.Symbol representing that symbol in this
@@ -465,9 +465,9 @@ blpy_is_valid (PyObject *self, PyObject *args)
 
   block = block_object_to_block (self);
   if (block == NULL)
-    Py_RETURN_FALSE;
+    return py_false ().release ();
 
-  Py_RETURN_TRUE;
+  return py_true ().release ();
 }
 
 /* Implementation of gdb.BlockIterator.is_valid (self) -> Boolean.
@@ -480,9 +480,9 @@ blpy_iter_is_valid (PyObject *self, PyObject *args)
     (block_syms_iterator_object *) self;
 
   if (iter_obj->source->block == NULL)
-    Py_RETURN_FALSE;
+    return py_false ().release ();
 
-  Py_RETURN_TRUE;
+  return py_true ().release ();
 }
 
 /* __repr__ implementation for gdb.Block.  */
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index d96c67694b3..68d4f77c608 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -139,8 +139,8 @@ bppy_is_valid (PyObject *self, PyObject *args)
   gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
 
   if (self_bp->bp)
-    Py_RETURN_TRUE;
-  Py_RETURN_FALSE;
+    return py_true ().release ();
+  return py_false ().release ();
 }
 
 /* Python function to test whether or not the breakpoint is enabled.  */
@@ -151,10 +151,10 @@ bppy_get_enabled (PyObject *self, void *closure)
 
   BPPY_REQUIRE_VALID (self_bp);
   if (! self_bp->bp)
-    Py_RETURN_FALSE;
+    return py_false ().release ();
   if (self_bp->bp->enable_state == bp_enabled)
-    Py_RETURN_TRUE;
-  Py_RETURN_FALSE;
+    return py_true ().release ();
+  return py_false ().release ();
 }
 
 /* Python function to test whether or not the breakpoint is silent.  */
@@ -165,8 +165,8 @@ bppy_get_silent (PyObject *self, void *closure)
 
   BPPY_REQUIRE_VALID (self_bp);
   if (self_bp->bp->silent)
-    Py_RETURN_TRUE;
-  Py_RETURN_FALSE;
+    return py_true ().release ();
+  return py_false ().release ();
 }
 
 /* Python function to set the enabled state of a breakpoint.  */
@@ -444,7 +444,7 @@ bppy_delete_breakpoint (PyObject *self, PyObject *args)
       return gdbpy_handle_gdb_exception (nullptr, except);
     }
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 
@@ -532,7 +532,7 @@ bppy_get_location (PyObject *self, void *closure)
 
   if (obj->bp->type != bp_breakpoint
       && obj->bp->type != bp_hardware_breakpoint)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   const char *str = obj->bp->locspec->to_string ();
   if (str == nullptr)
@@ -550,7 +550,7 @@ bppy_get_expression (PyObject *self, void *closure)
   BPPY_REQUIRE_VALID (obj);
 
   if (!is_watchpoint (obj->bp))
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   watchpoint *wp = gdb::checked_static_cast<watchpoint *> (obj->bp);
 
@@ -572,7 +572,7 @@ bppy_get_condition (PyObject *self, void *closure)
 
   str = obj->bp->cond_string.get ();
   if (! str)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   return host_string_to_python_string (str).release ();
 }
@@ -627,7 +627,7 @@ bppy_get_commands (PyObject *self, void *closure)
   BPPY_REQUIRE_VALID (self_bp);
 
   if (! self_bp->bp->commands)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   string_file stb;
 
@@ -703,9 +703,9 @@ bppy_get_visibility (PyObject *self, void *closure)
   BPPY_REQUIRE_VALID (self_bp);
 
   if (user_breakpoint_p (self_bp->bp))
-    Py_RETURN_TRUE;
+    return py_true ().release ();
 
-  Py_RETURN_FALSE;
+  return py_false ().release ();
 }
 
 /* Python function to determine if the breakpoint is a temporary
@@ -720,9 +720,9 @@ bppy_get_temporary (PyObject *self, void *closure)
 
   if (self_bp->bp->disposition == disp_del
       || self_bp->bp->disposition == disp_del_at_next_stop)
-    Py_RETURN_TRUE;
+    return py_true ().release ();
 
-  Py_RETURN_FALSE;
+  return py_false ().release ();
 }
 
 /* Python function to determine if the breakpoint is a pending
@@ -736,11 +736,11 @@ bppy_get_pending (PyObject *self, void *closure)
   BPPY_REQUIRE_VALID (self_bp);
 
   if (is_watchpoint (self_bp->bp))
-    Py_RETURN_FALSE;
+    return py_false ().release ();
   if (pending_breakpoint_p (self_bp->bp))
-    Py_RETURN_TRUE;
+    return py_true ().release ();
 
-  Py_RETURN_FALSE;
+  return py_false ().release ();
 }
 
 /* Python function to get the breakpoint's number.  */
@@ -763,7 +763,7 @@ bppy_get_thread (PyObject *self, void *closure)
   BPPY_REQUIRE_VALID (self_bp);
 
   if (self_bp->bp->thread == -1)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   return gdb_py_object_from_longest (self_bp->bp->thread).release ();
 }
@@ -777,7 +777,7 @@ bppy_get_inferior (PyObject *self, void *closure)
   BPPY_REQUIRE_VALID (self_bp);
 
   if (self_bp->bp->inferior == -1)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   return gdb_py_object_from_longest (self_bp->bp->inferior).release ();
 }
@@ -791,7 +791,7 @@ bppy_get_task (PyObject *self, void *closure)
   BPPY_REQUIRE_VALID (self_bp);
 
   if (self_bp->bp->task == -1)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   return gdb_py_object_from_longest (self_bp->bp->task).release ();
 }
@@ -1598,9 +1598,9 @@ bplocpy_get_enabled (PyObject *py_self, void *closure)
   BPLOCPY_REQUIRE_VALID (self->owner, self);
 
   if (self->bp_loc->enabled)
-    Py_RETURN_TRUE;
+    return py_true ().release ();
   else
-    Py_RETURN_FALSE;
+    return py_false ().release ();
 }
 
 /* Python function to get address of breakpoint location.  */
@@ -1673,7 +1673,7 @@ bplocpy_get_source_location (PyObject *py_self, void *closure)
       return tup.release ();
     }
   else
-    Py_RETURN_NONE;
+    return py_none ().release ();
 }
 
 /* Python function to get the function name of where this location was set.  */
@@ -1687,7 +1687,7 @@ bplocpy_get_function (PyObject *py_self, void *closure)
   const auto fn_name = self->bp_loc->function_name.get ();
   if (fn_name != nullptr)
     return host_string_to_python_string (fn_name).release ();
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 static PyObject *
@@ -1726,7 +1726,7 @@ bplocpy_get_fullname (PyObject *py_self, void *closure)
 	= host_string_to_python_string (symtab->fullname ());
       return fullname.release ();
     }
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* De-allocation function to be called for the Python object.  */
diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c
index 3fbc26b0cde..bcb1ba37d93 100644
--- a/gdb/python/py-cmd.c
+++ b/gdb/python/py-cmd.c
@@ -76,7 +76,7 @@ static PyObject *
 cmdpy_dont_repeat (PyObject *self, PyObject *args)
 {
   dont_repeat ();
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 \f
diff --git a/gdb/python/py-connection.c b/gdb/python/py-connection.c
index a8bea4d832f..2d0b2e94659 100644
--- a/gdb/python/py-connection.c
+++ b/gdb/python/py-connection.c
@@ -216,9 +216,9 @@ connpy_is_valid (PyObject *self, PyObject *args)
   connection_object *conn = (connection_object *) self;
 
   if (conn->target == nullptr)
-    Py_RETURN_FALSE;
+    return py_false ().release ();
 
-  Py_RETURN_TRUE;
+  return py_true ().release ();
 }
 
 /* Return the id number of this connection.  */
@@ -274,7 +274,7 @@ connpy_get_connection_details (PyObject *self, void *closure)
   if (details != nullptr)
     return host_string_to_python_string (details).release ();
   else
-    Py_RETURN_NONE;
+    return py_none ().release ();
 }
 
 /* Python specific initialization for this file.  */
diff --git a/gdb/python/py-corefile.c b/gdb/python/py-corefile.c
index 0fa4e90488c..2c5596d093c 100644
--- a/gdb/python/py-corefile.c
+++ b/gdb/python/py-corefile.c
@@ -199,9 +199,9 @@ cfpy_is_valid (PyObject *self, PyObject *args)
   corefile_object *obj = (corefile_object *) self;
 
   if (!cfpy_corefile_object_is_valid (obj))
-    Py_RETURN_FALSE;
+    return py_false ().release ();
 
-  Py_RETURN_TRUE;
+  return py_true ().release ();
 }
 
 /* Implement gdb.Corefile.mapped_files ().  Return a List of
@@ -469,9 +469,9 @@ cfmf_is_main_exec (PyObject *self, void *closure)
     = (corefile_mapped_file_object *) self;
 
   if (obj->is_main_exec_p)
-    Py_RETURN_TRUE;
+    return py_true ().release ();
   else
-    Py_RETURN_FALSE;
+    return py_false ().release ();
 }
 
 \f
diff --git a/gdb/python/py-disasm.c b/gdb/python/py-disasm.c
index 1c5661dd307..d4d50e90035 100644
--- a/gdb/python/py-disasm.c
+++ b/gdb/python/py-disasm.c
@@ -318,9 +318,9 @@ disasmpy_info_is_valid (PyObject *self, PyObject *args)
   disasm_info_object *disasm_obj = (disasm_info_object *) self;
 
   if (disasm_info_object_is_valid (disasm_obj))
-    Py_RETURN_TRUE;
+    return py_true ().release ();
 
-  Py_RETURN_FALSE;
+  return py_false ().release ();
 }
 
 /* Set the Python exception to be a gdb.MemoryError object, with ADDRESS
@@ -625,7 +625,7 @@ disasmpy_set_enabled (PyObject *self, PyObject *args, PyObject *kw)
     return nullptr;
 
   python_print_insn_enabled = newstate == Py_True;
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Implement DisassembleInfo.read_memory(LENGTH, OFFSET).  Read LENGTH
diff --git a/gdb/python/py-evtregistry.c b/gdb/python/py-evtregistry.c
index 9d12d0161f1..8d2a68da2a4 100644
--- a/gdb/python/py-evtregistry.c
+++ b/gdb/python/py-evtregistry.c
@@ -45,7 +45,7 @@ evregpy_connect (PyObject *self, PyObject *function)
   if (PyList_Append (callback_list, func) < 0)
     return NULL;
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Implementation of EventRegistry.disconnect () -> NULL.
@@ -63,12 +63,12 @@ evregpy_disconnect (PyObject *self, PyObject *function)
 
   index = PySequence_Index (callback_list, func);
   if (index < 0)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   if (PySequence_DelItem (callback_list, index) < 0)
     return NULL;
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Create a new event registry.  This function uses PyObject_New
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
index fbbb705a864..f85f4fff766 100644
--- a/gdb/python/py-finishbreakpoint.c
+++ b/gdb/python/py-finishbreakpoint.c
@@ -73,7 +73,7 @@ bpfinishpy_get_returnvalue (PyObject *self, void *closure)
       (struct finish_breakpoint_object *) self;
 
   if (!self_finishbp->return_value)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   Py_INCREF (self_finishbp->return_value);
   return self_finishbp->return_value;
diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c
index 1420d2ac5b9..2a674ba52f8 100644
--- a/gdb/python/py-frame.c
+++ b/gdb/python/py-frame.c
@@ -119,9 +119,9 @@ frapy_is_valid (PyObject *self, PyObject *args)
     }
 
   if (frame == NULL)
-    Py_RETURN_FALSE;
+    return py_false ().release ();
 
-  Py_RETURN_TRUE;
+  return py_true ().release ();
 }
 
 /* Implementation of gdb.Frame.name (self) -> String.
@@ -354,7 +354,7 @@ frapy_function (PyObject *self, PyObject *args)
   if (sym)
     return symbol_to_symbol_object (sym).release ();
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Convert a frame_info struct to a Python Frame object.
@@ -583,7 +583,7 @@ frapy_select (PyObject *self, PyObject *args)
       return gdbpy_handle_gdb_exception (nullptr, except);
     }
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* The stack frame level for this frame.  */
@@ -645,7 +645,7 @@ frapy_static_link (PyObject *self, PyObject *args)
     }
 
   if (link == nullptr)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   return frame_info_to_frame_object (link).release ();
 }
@@ -739,8 +739,8 @@ frapy_richcompare (PyObject *self, PyObject *other, int op)
     result = Py_NE;
 
   if (op == result)
-    Py_RETURN_TRUE;
-  Py_RETURN_FALSE;
+    return py_true ().release ();
+  return py_false ().release ();
 }
 
 /* Sets up the Frame API in the gdb module.  */
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
index 26172d9f80e..f256a26807c 100644
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -279,7 +279,7 @@ get_py_iter_from_func (PyObject *filter, const char *func)
 	}
     }
   else
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   return NULL;
 }
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index 1a30f4ee378..d2fc159c227 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -439,7 +439,7 @@ infpy_get_connection_num (PyObject *self, void *closure)
 
   process_stratum_target *target = inf->inferior->process_target ();
   if (target == nullptr)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   return gdb_py_object_from_longest (target->connection_number).release ();
 }
@@ -461,8 +461,8 @@ infpy_get_was_attached (PyObject *self, void *closure)
 
   INFPY_REQUIRE_VALID (inf);
   if (inf->inferior->attach_flag)
-    Py_RETURN_TRUE;
-  Py_RETURN_FALSE;
+    return py_true ().release ();
+  return py_false ().release ();
 }
 
 /* Getter of gdb.Inferior.progspace.  */
@@ -609,7 +609,7 @@ infpy_write_memory (PyObject *self, PyObject *args, PyObject *kw)
       return gdbpy_handle_gdb_exception (nullptr, ex);
     }
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Implementation of
@@ -686,7 +686,7 @@ infpy_search_memory (PyObject *self, PyObject *args, PyObject *kw)
   if (found)
     return gdb_py_object_from_ulongest (found_addr).release ();
   else
-    Py_RETURN_NONE;
+    return py_none ().release ();
 }
 
 /* Implementation of gdb.Inferior.is_valid (self) -> Boolean.
@@ -698,9 +698,9 @@ infpy_is_valid (PyObject *self, PyObject *args)
   inferior_object *inf = (inferior_object *) self;
 
   if (! inf->inferior)
-    Py_RETURN_FALSE;
+    return py_false ().release ();
 
-  Py_RETURN_TRUE;
+  return py_true ().release ();
 }
 
 /* Implementation of gdb.Inferior.thread_from_handle (self, handle)
@@ -759,7 +759,7 @@ infpy_thread_from_thread_handle (PyObject *self, PyObject *args, PyObject *kw)
       return gdbpy_handle_gdb_exception (nullptr, except);
     }
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Implementation of gdb.Inferior.architecture.  */
@@ -799,7 +799,7 @@ infpy_clear_env (PyObject *obj)
   INFPY_REQUIRE_VALID (self);
 
   self->inferior->environment.clear ();
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Implement set_env.  */
@@ -818,7 +818,7 @@ infpy_set_env (PyObject *obj, PyObject *args, PyObject *kw)
     return nullptr;
 
   self->inferior->environment.set (name, val);
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Implement unset_env.  */
@@ -835,7 +835,7 @@ infpy_unset_env (PyObject *obj, PyObject *args, PyObject *kw)
     return nullptr;
 
   self->inferior->environment.unset (name);
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Getter for "arguments".  */
@@ -849,7 +849,7 @@ infpy_get_args (PyObject *self, void *closure)
 
   const std::string &args = inf->inferior->args ();
   if (args.empty ())
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   return host_string_to_python_string (args.c_str ()).release ();
 }
@@ -938,7 +938,7 @@ infpy_get_main_name (PyObject *self, void *closure)
     }
 
   if (name == nullptr)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   return host_string_to_python_string (name).release ();
 }
diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c
index 672546e106d..ddb67a284ac 100644
--- a/gdb/python/py-infthread.c
+++ b/gdb/python/py-infthread.c
@@ -77,7 +77,7 @@ thpy_get_name (PyObject *self, void *ignore)
 
   const char *name = thread_name (thread_obj->thread);
   if (name == NULL)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   return PyUnicode_FromString (name);
 }
@@ -105,7 +105,7 @@ thpy_get_details (PyObject *self, void *ignore)
       return gdbpy_handle_gdb_exception (nullptr, except);
     }
   if (extra_info == nullptr)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   return PyUnicode_FromString (extra_info);
 }
@@ -246,7 +246,7 @@ thpy_switch (PyObject *self, PyObject *args)
       return gdbpy_handle_gdb_exception (nullptr, except);
     }
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Implementation of InferiorThread.is_stopped () -> Boolean.
@@ -260,9 +260,9 @@ thpy_is_stopped (PyObject *self, PyObject *args)
   THPY_REQUIRE_VALID (thread_obj);
 
   if (thread_obj->thread->state () == THREAD_STOPPED)
-    Py_RETURN_TRUE;
+    return py_true ().release ();
 
-  Py_RETURN_FALSE;
+  return py_false ().release ();
 }
 
 /* Implementation of InferiorThread.is_running () -> Boolean.
@@ -276,9 +276,9 @@ thpy_is_running (PyObject *self, PyObject *args)
   THPY_REQUIRE_VALID (thread_obj);
 
   if (thread_obj->thread->state () == THREAD_RUNNING)
-    Py_RETURN_TRUE;
+    return py_true ().release ();
 
-  Py_RETURN_FALSE;
+  return py_false ().release ();
 }
 
 /* Implementation of InferiorThread.is_exited () -> Boolean.
@@ -292,9 +292,9 @@ thpy_is_exited (PyObject *self, PyObject *args)
   THPY_REQUIRE_VALID (thread_obj);
 
   if (thread_obj->thread->state () == THREAD_EXITED)
-    Py_RETURN_TRUE;
+    return py_true ().release ();
 
-  Py_RETURN_FALSE;
+  return py_false ().release ();
 }
 
 /* Implementation of gdb.InfThread.is_valid (self) -> Boolean.
@@ -307,9 +307,9 @@ thpy_is_valid (PyObject *self, PyObject *args)
   thread_object *thread_obj = (thread_object *) self;
 
   if (! thread_obj->thread)
-    Py_RETURN_FALSE;
+    return py_false ().release ();
 
-  Py_RETURN_TRUE;
+  return py_true ().release ();
 }
 
 /* Implementation of gdb.InferiorThread.handle (self) -> handle. */
@@ -400,7 +400,7 @@ gdbpy_selected_thread (PyObject *self, PyObject *args)
   if (inferior_ptid != null_ptid)
     return thread_to_thread_object (inferior_thread ()).release ();
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 static int
diff --git a/gdb/python/py-linetable.c b/gdb/python/py-linetable.c
index 2afa9b033e7..d2d85026a32 100644
--- a/gdb/python/py-linetable.c
+++ b/gdb/python/py-linetable.c
@@ -124,7 +124,7 @@ build_line_table_tuple_from_entries
   int i;
 
   if (entries.size () < 1)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   gdbpy_ref<> tuple (PyTuple_New (entries.size ()));
 
@@ -204,10 +204,10 @@ ltpy_has_line (PyObject *self, PyObject *args)
     {
       const linetable_entry *item = &(symtab->linetable ()->item[index]);
       if (item->line == py_line)
-	  Py_RETURN_TRUE;
+	  return py_true ().release ();
     }
 
-  Py_RETURN_FALSE;
+  return py_false ().release ();
 }
 
 /* Implementation of gdb.LineTable.source_lines (self) -> List.
@@ -266,9 +266,9 @@ ltpy_is_valid (PyObject *self, PyObject *args)
   symtab = symtab_object_to_symtab (get_symtab (self));
 
   if (symtab == NULL)
-    Py_RETURN_FALSE;
+    return py_false ().release ();
 
-  Py_RETURN_TRUE;
+  return py_true ().release ();
 }
 
 /* Deconstructor for the line table object.  Decrement the reference
@@ -427,9 +427,9 @@ ltpy_iter_is_valid (PyObject *self, PyObject *args)
   symtab = symtab_object_to_symtab (get_symtab (iter_obj->source));
 
   if (symtab == NULL)
-    Py_RETURN_FALSE;
+    return py_false ().release ();
 
-  Py_RETURN_TRUE;
+  return py_true ().release ();
 }
 
 GDBPY_INITIALIZE_FILE (gdbpy_initialize_linetable);
diff --git a/gdb/python/py-mi.c b/gdb/python/py-mi.c
index 27c79d60636..1bcb276da8a 100644
--- a/gdb/python/py-mi.c
+++ b/gdb/python/py-mi.c
@@ -406,5 +406,5 @@ gdbpy_notify_mi (PyObject *self, PyObject *args, PyObject *kwargs)
       gdb_flush (mi->event_channel);
     }
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
diff --git a/gdb/python/py-micmd.c b/gdb/python/py-micmd.c
index 6edea04ccb5..73f5297bd70 100644
--- a/gdb/python/py-micmd.c
+++ b/gdb/python/py-micmd.c
@@ -490,8 +490,8 @@ micmdpy_get_installed (PyObject *self, void *closure)
   struct micmdpy_object *micmd_obj = (struct micmdpy_object *) self;
 
   if (micmd_obj->mi_command == nullptr)
-    Py_RETURN_FALSE;
-  Py_RETURN_TRUE;
+    return py_false ().release ();
+  return py_true ().release ();
 }
 
 /* Set the gdb.MICommand.installed property.  The property can be set to
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index d427f149429..ec8b82fbe13 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -87,7 +87,7 @@ objfpy_get_filename (PyObject *self, void *closure)
   if (obj->objfile)
     return (host_string_to_python_string (objfile_name (obj->objfile))
 	    .release ());
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* An Objfile method which returns the objfile's file name, as specified
@@ -105,7 +105,7 @@ objfpy_get_username (PyObject *self, void *closure)
       return host_string_to_python_string (username).release ();
     }
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Get the 'is_file' attribute.  */
@@ -117,7 +117,7 @@ objfpy_get_is_file (PyObject *o, void *ignore)
 
   if (self->objfile != nullptr)
     return PyBool_FromLong ((self->objfile->flags & OBJF_NOT_FILENAME) == 0);
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* If SELF is a separate debug-info file, return the "backlink" field.
@@ -135,7 +135,7 @@ objfpy_get_owner (PyObject *self, void *closure)
   owner = objfile->separate_debug_objfile_backlink;
   if (owner != NULL)
     return objfile_to_objfile_object (owner).release ();
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* An Objfile method which returns the objfile's build id, or None.  */
@@ -165,7 +165,7 @@ objfpy_get_build_id (PyObject *self, void *closure)
       return host_string_to_python_string (hex_form.c_str ()).release ();
     }
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* An Objfile method which returns the objfile's progspace, or None.  */
@@ -178,7 +178,7 @@ objfpy_get_progspace (PyObject *self, void *closure)
   if (obj->objfile)
     return pspace_to_pspace_object (obj->objfile->pspace ()).release ();
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 static void
@@ -415,9 +415,9 @@ objfpy_is_valid (PyObject *self, PyObject *args)
   objfile_object *obj = (objfile_object *) self;
 
   if (! obj->objfile)
-    Py_RETURN_FALSE;
+    return py_false ().release ();
 
-  Py_RETURN_TRUE;
+  return py_true ().release ();
 }
 
 /* Implementation of gdb.Objfile.add_separate_debug_file (self, string). */
@@ -445,7 +445,7 @@ objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
       return gdbpy_handle_gdb_exception (nullptr, except);
     }
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Implementation of
@@ -471,7 +471,7 @@ objfpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
       struct symbol *sym = lookup_global_symbol_from_objfile
 	(obj->objfile, GLOBAL_BLOCK, symbol_name, flags).symbol;
       if (sym == nullptr)
-	Py_RETURN_NONE;
+	return py_none ().release ();
 
       return symbol_to_symbol_object (sym).release ();
     }
@@ -504,7 +504,7 @@ objfpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw)
       struct symbol *sym = lookup_global_symbol_from_objfile
 	(obj->objfile, STATIC_BLOCK, symbol_name, flags).symbol;
       if (sym == nullptr)
-	Py_RETURN_NONE;
+	return py_none ().release ();
 
       return symbol_to_symbol_object (sym).release ();
     }
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index 0cf0cde881c..a561196a2a9 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -119,7 +119,7 @@ find_pretty_printer_from_objfiles (PyObject *value)
 	return function.release ();
     }
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Subroutine of find_pretty_printer to simplify it.
diff --git a/gdb/python/py-progspace.c b/gdb/python/py-progspace.c
index 37b92a64634..48e52328e9c 100644
--- a/gdb/python/py-progspace.c
+++ b/gdb/python/py-progspace.c
@@ -106,7 +106,7 @@ pspy_get_filename (PyObject *self, void *closure)
 	return (host_string_to_python_string (objfile_name (objfile))
 		.release ());
     }
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Implement the gdb.Progspace.symbol_file attribute.  Return the
@@ -126,7 +126,7 @@ pspy_get_symbol_file (PyObject *self, void *closure)
   if (objfile != nullptr)
     return objfile_to_objfile_object (objfile).release ();
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Implement the gdb.Progspace.executable_filename attribute.  Return a
@@ -145,7 +145,7 @@ pspy_get_exec_file (PyObject *self, void *closure)
   if (filename != nullptr)
     return host_string_to_python_string (filename).release ();
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 static void
@@ -456,7 +456,7 @@ pspy_solib_name (PyObject *o, PyObject *args)
 
   const char *soname = solib_name_from_address (self->pspace, pc);
   if (soname == nullptr)
-    Py_RETURN_NONE;
+    return py_none ().release ();
   return host_string_to_python_string (soname).release ();
 }
 
@@ -479,7 +479,7 @@ pspy_objfile_for_address (PyObject *o, PyObject *args)
 
   struct objfile *objf = self->pspace->objfile_for_address (addr);
   if (objf == nullptr)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   return objfile_to_objfile_object (objf).release ();
 }
@@ -518,12 +518,12 @@ pspy_block_for_pc (PyObject *o, PyObject *args)
     }
 
   if (cust == NULL || cust->objfile () == NULL)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   if (block)
     return block_to_block_object (block, cust->objfile ()).release ();
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Implementation of the find_pc_line function.
@@ -568,9 +568,9 @@ pspy_is_valid (PyObject *o, PyObject *args)
   pspace_object *self = (pspace_object *) o;
 
   if (self->pspace == NULL)
-    Py_RETURN_FALSE;
+    return py_false ().release ();
 
-  Py_RETURN_TRUE;
+  return py_true ().release ();
 }
 
 \f
diff --git a/gdb/python/py-record-btrace.c b/gdb/python/py-record-btrace.c
index 6026de91e67..5f1c93170c6 100644
--- a/gdb/python/py-record-btrace.c
+++ b/gdb/python/py-record-btrace.c
@@ -262,9 +262,9 @@ recpy_bt_insn_is_speculative (PyObject *self, void *closure)
     return NULL;
 
   if (insn->flags & BTRACE_INSN_FLAG_SPECULATIVE)
-    Py_RETURN_TRUE;
+    return py_true ().release ();
   else
-    Py_RETURN_FALSE;
+    return py_false ().release ();
 }
 
 /* Implementation of RecordInstruction.data [buffer] for btrace.
@@ -352,7 +352,7 @@ recpy_bt_func_symbol (PyObject *self, void *closure)
     return NULL;
 
   if (func->sym == NULL)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   return symbol_to_symbol_object (func->sym).release ();
 }
@@ -392,7 +392,7 @@ recpy_bt_func_up (PyObject *self, void *closure)
     return NULL;
 
   if (func->up == 0)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   return recpy_func_new (((recpy_element_object *) self)->thread,
 			 RECORD_METHOD_BTRACE, func->up);
@@ -410,7 +410,7 @@ recpy_bt_func_prev (PyObject *self, void *closure)
     return NULL;
 
   if (func->prev == 0)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   return recpy_func_new (((recpy_element_object *) self)->thread,
 			 RECORD_METHOD_BTRACE, func->prev);
@@ -428,7 +428,7 @@ recpy_bt_func_next (PyObject *self, void *closure)
     return NULL;
 
   if (func->next == 0)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   return recpy_func_new (((recpy_element_object *) self)->thread,
 			 RECORD_METHOD_BTRACE, func->next);
@@ -634,9 +634,9 @@ btpy_list_richcompare (PyObject *self, PyObject *other, int op)
 	  && obj1->first == obj2->first
 	  && obj1->last == obj2->last
 	  && obj1->step == obj2->step)
-	Py_RETURN_TRUE;
+	return py_true ().release ();
       else
-	Py_RETURN_FALSE;
+	return py_false ().release ();
 
     case Py_NE:
       if (obj1->thread != obj2->thread
@@ -644,9 +644,9 @@ btpy_list_richcompare (PyObject *self, PyObject *other, int op)
 	  || obj1->first != obj2->first
 	  || obj1->last != obj2->last
 	  || obj1->step != obj2->step)
-	Py_RETURN_TRUE;
+	return py_true ().release ();
       else
-	Py_RETURN_FALSE;
+	return py_false ().release ();
 
     default:
       break;
@@ -676,12 +676,12 @@ recpy_bt_format (PyObject *self, void *closure)
   const struct btrace_config * config;
 
   if (tinfo == NULL)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   config = btrace_conf (&tinfo->btrace);
 
   if (config == NULL)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   return PyUnicode_FromString (btrace_format_short_string (config->format));
 }
@@ -696,10 +696,10 @@ recpy_bt_replay_position (PyObject *self, void *closure)
   thread_info * tinfo = record->thread;
 
   if (tinfo == NULL)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   if (tinfo->btrace.replay == NULL)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   return btpy_item_new (tinfo, btrace_insn_number (tinfo->btrace.replay));
 }
@@ -715,12 +715,12 @@ recpy_bt_begin (PyObject *self, void *closure)
   struct btrace_insn_iterator iterator;
 
   if (tinfo == NULL)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   btrace_fetch (tinfo, record_btrace_get_cpu ());
 
   if (btrace_is_empty (tinfo))
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   btrace_insn_begin (&iterator, &tinfo->btrace);
   return btpy_item_new (tinfo, btrace_insn_number (&iterator));
@@ -737,12 +737,12 @@ recpy_bt_end (PyObject *self, void *closure)
   struct btrace_insn_iterator iterator;
 
   if (tinfo == NULL)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   btrace_fetch (tinfo, record_btrace_get_cpu ());
 
   if (btrace_is_empty (tinfo))
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   btrace_insn_end (&iterator, &tinfo->btrace);
   return btpy_item_new (tinfo, btrace_insn_number (&iterator));
@@ -761,12 +761,12 @@ recpy_bt_instruction_history (PyObject *self, void *closure)
   unsigned long last = 0;
 
    if (tinfo == NULL)
-     Py_RETURN_NONE;
+     return py_none ().release ();
 
    btrace_fetch (tinfo, record_btrace_get_cpu ());
 
    if (btrace_is_empty (tinfo))
-     Py_RETURN_NONE;
+     return py_none ().release ();
 
    btrace_insn_begin (&iterator, &tinfo->btrace);
    first = btrace_insn_number (&iterator);
@@ -790,12 +790,12 @@ recpy_bt_function_call_history (PyObject *self, void *closure)
   unsigned long last = 0;
 
   if (tinfo == NULL)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   btrace_fetch (tinfo, record_btrace_get_cpu ());
 
   if (btrace_is_empty (tinfo))
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   btrace_call_begin (&iterator, &tinfo->btrace);
   first = btrace_call_number (&iterator);
@@ -943,7 +943,7 @@ recpy_bt_goto (PyObject *self, PyObject *args)
       return gdbpy_handle_gdb_exception (nullptr, except);
     }
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Implementation of BtraceRecord.clear (self) -> None.  */
@@ -956,7 +956,7 @@ recpy_bt_clear (PyObject *self, PyObject *args)
 
   btrace_clear (tinfo);
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* BtraceList methods.  */
diff --git a/gdb/python/py-record.c b/gdb/python/py-record.c
index 294da0725e1..753826f88c4 100644
--- a/gdb/python/py-record.c
+++ b/gdb/python/py-record.c
@@ -427,17 +427,17 @@ recpy_element_richcompare (PyObject *self, PyObject *other, int op)
       if (obj1->thread == obj2->thread
 	  && obj1->method == obj2->method
 	  && obj1->number == obj2->number)
-	Py_RETURN_TRUE;
+	return py_true ().release ();
       else
-	Py_RETURN_FALSE;
+	return py_false ().release ();
 
     case Py_NE:
       if (obj1->thread != obj2->thread
 	  || obj1->method != obj2->method
 	  || obj1->number != obj2->number)
-	Py_RETURN_TRUE;
+	return py_true ().release ();
       else
-	Py_RETURN_FALSE;
+	return py_false ().release ();
 
     default:
       break;
@@ -691,7 +691,7 @@ gdbpy_current_recording (PyObject *self, PyObject *args)
   recpy_record_object *ret = NULL;
 
   if (find_record_target () == NULL)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   ret = PyObject_New (recpy_record_object, &recpy_record_type);
   if (ret == nullptr)
@@ -717,7 +717,7 @@ gdbpy_stop_recording (PyObject *self, PyObject *args)
       return gdbpy_handle_gdb_exception (nullptr, except);
     }
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 GDBPY_INITIALIZE_FILE (gdbpy_initialize_record);
diff --git a/gdb/python/py-registers.c b/gdb/python/py-registers.c
index c6e0748e935..14cf19a6e66 100644
--- a/gdb/python/py-registers.c
+++ b/gdb/python/py-registers.c
@@ -348,7 +348,7 @@ register_descriptor_iter_find (PyObject *self, PyObject *args, PyObject *kw)
 	return gdbpy_get_register_descriptor (gdbarch, regnum).release ();
     }
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* See python-internal.h.  */
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index 6293b658ea1..bf803a3b487 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -84,7 +84,7 @@ sympy_get_symtab (PyObject *self, void *closure)
   SYMPY_REQUIRE_VALID (self, symbol);
 
   if (!symbol->is_objfile_owned ())
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   return symtab_to_symtab_object (symbol->symtab ()).release ();
 }
@@ -224,8 +224,8 @@ sympy_needs_frame (PyObject *self, void *closure)
     }
 
   if (result)
-    Py_RETURN_TRUE;
-  Py_RETURN_FALSE;
+    return py_true ().release ();
+  return py_false ().release ();
 }
 
 /* Implementation of gdb.Symbol.line -> int.
@@ -251,9 +251,9 @@ sympy_is_valid (PyObject *self, PyObject *args)
 
   symbol = symbol_object_to_symbol (self);
   if (symbol == NULL)
-    Py_RETURN_FALSE;
+    return py_false ().release ();
 
-  Py_RETURN_TRUE;
+  return py_true ().release ();
 }
 
 /* Implementation of gdb.Symbol.value (self[, frame]) -> gdb.Value.  Returns
diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c
index c5e18543740..f1fbfa58d65 100644
--- a/gdb/python/py-symtab.c
+++ b/gdb/python/py-symtab.c
@@ -146,7 +146,7 @@ stpy_get_producer (PyObject *self, void *closure)
       return host_string_to_python_string (producer).release ();
     }
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 static PyObject *
@@ -172,9 +172,9 @@ stpy_is_valid (PyObject *self, PyObject *args)
 
   symtab = symtab_object_to_symtab (self);
   if (symtab == NULL)
-    Py_RETURN_FALSE;
+    return py_false ().release ();
 
-  Py_RETURN_TRUE;
+  return py_true ().release ();
 }
 
 /* Return the GLOBAL_BLOCK of the underlying symtab.  */
@@ -247,7 +247,7 @@ stpy_source_lines (PyObject *self, PyObject *args, PyObject *kw)
 
   std::optional<int> last_lineno = last_symtab_line (symtab);
   if (!last_lineno.has_value ())
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
 
   if (first < 1)
@@ -294,7 +294,7 @@ stpy_source_lines (PyObject *self, PyObject *args, PyObject *kw)
 	  = make_scoped_restore (&source_styling, required_styling);
 
 	if (!g_source_cache.get_source_lines (symtab, first, last, &lines))
-	  Py_RETURN_NONE;
+	  return py_none ().release ();
       }
 
       gdbpy_ref<> list (PyList_New (0));
@@ -387,7 +387,7 @@ salpy_get_last (PyObject *self, void *closure)
   if (sal->end > 0)
     return gdb_py_object_from_ulongest (sal->end - 1).release ();
   else
-    Py_RETURN_NONE;
+    return py_none ().release ();
 }
 
 static PyObject *
@@ -408,7 +408,7 @@ salpy_get_symtab (PyObject *self, void *closure)
   SALPY_REQUIRE_VALID (self, sal);
 
   if (sal->symtab == nullptr)
-    Py_RETURN_NONE;
+    return py_none ().release ();
   else
     return symtab_to_symtab_object (sal->symtab).release ();
 }
@@ -423,9 +423,9 @@ salpy_is_valid (PyObject *self, PyObject *args)
 
   sal = sal_object_to_symtab_and_line (self);
   if (sal == NULL)
-    Py_RETURN_FALSE;
+    return py_false ().release ();
 
-  Py_RETURN_TRUE;
+  return py_true ().release ();
 }
 
 static void
diff --git a/gdb/python/py-tui.c b/gdb/python/py-tui.c
index be19193770f..111e0f4c9e3 100644
--- a/gdb/python/py-tui.c
+++ b/gdb/python/py-tui.c
@@ -428,7 +428,7 @@ gdbpy_register_tui_window (PyObject *self, PyObject *args, PyObject *kw)
       return gdbpy_handle_gdb_exception (nullptr, except);
     }
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 \f
@@ -462,8 +462,8 @@ gdbpy_tui_is_valid (PyObject *self, PyObject *args)
   gdbpy_tui_window *win = (gdbpy_tui_window *) self;
 
   if (win->is_valid ())
-    Py_RETURN_TRUE;
-  Py_RETURN_FALSE;
+    return py_true ().release ();
+  return py_false ().release ();
 }
 
 /* Python function that erases the TUI window.  */
@@ -476,7 +476,7 @@ gdbpy_tui_erase (PyObject *self, PyObject *args)
 
   win->window->erase ();
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Python function that writes some text to a TUI window.  */
@@ -497,7 +497,7 @@ gdbpy_tui_write (PyObject *self, PyObject *args, PyObject *kw)
 
   win->window->output (text, full_window);
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Return the width of the TUI window.  */
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index 263d48a9365..89ff19cd759 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -349,7 +349,7 @@ typy_get_name (PyObject *self, void *closure)
   struct type *type = ((type_object *) self)->type;
 
   if (type->name () == NULL)
-    Py_RETURN_NONE;
+    return py_none ().release ();
   /* Ada type names are encoded, but it is better for users to see the
      decoded form.  */
   if (ADA_TYPE_P (type))
@@ -374,7 +374,7 @@ typy_get_tag (PyObject *self, void *closure)
     tagname = type->name ();
 
   if (tagname == nullptr)
-    Py_RETURN_NONE;
+    return py_none ().release ();
   return PyUnicode_FromString (tagname);
 }
 
@@ -386,7 +386,7 @@ typy_get_objfile (PyObject *self, void *closure)
   struct objfile *objfile = type->objfile_owner ();
 
   if (objfile == nullptr)
-    Py_RETURN_NONE;
+    return py_none ().release ();
   return objfile_to_objfile_object (objfile).release ();
 }
 
@@ -398,9 +398,9 @@ typy_is_scalar (PyObject *self, void *closure)
   struct type *type = ((type_object *) self)->type;
 
   if (is_scalar_type (type))
-    Py_RETURN_TRUE;
+    return py_true ().release ();
   else
-    Py_RETURN_FALSE;
+    return py_false ().release ();
 }
 
 /* Return true if this type is signed.  Raises a ValueError if this type
@@ -419,9 +419,9 @@ typy_is_signed (PyObject *self, void *closure)
     }
 
   if (type->is_unsigned ())
-    Py_RETURN_FALSE;
+    return py_false ().release ();
   else
-    Py_RETURN_TRUE;
+    return py_true ().release ();
 }
 
 /* Return true if this type is array-like.  */
@@ -443,9 +443,9 @@ typy_is_array_like (PyObject *self, void *closure)
     }
 
   if (result)
-    Py_RETURN_TRUE;
+    return py_true ().release ();
   else
-    Py_RETURN_FALSE;
+    return py_false ().release ();
 }
 
 /* Return true if this type is string-like.  */
@@ -467,9 +467,9 @@ typy_is_string_like (PyObject *self, void *closure)
     }
 
   if (result)
-    Py_RETURN_TRUE;
+    return py_true ().release ();
   else
-    Py_RETURN_FALSE;
+    return py_false ().release ();
 }
 
 /* Return the type, stripped of typedefs. */
@@ -777,7 +777,7 @@ typy_get_sizeof (PyObject *self, void *closure)
   /* Ignore exceptions.  */
 
   if (size_varies)
-    Py_RETURN_NONE;
+    return py_none ().release ();
   return gdb_py_object_from_longest (type->length ()).release ();
 }
 
@@ -819,8 +819,8 @@ typy_get_dynamic (PyObject *self, void *closure)
     }
 
   if (result)
-    Py_RETURN_TRUE;
-  Py_RETURN_FALSE;
+    return py_true ().release ();
+  return py_false ().release ();
 }
 
 static struct type *
@@ -1140,8 +1140,8 @@ typy_richcompare (PyObject *self, PyObject *other, int op)
     }
 
   if (op == (result ? Py_EQ : Py_NE))
-    Py_RETURN_TRUE;
-  Py_RETURN_FALSE;
+    return py_true ().release ();
+  return py_false ().release ();
 }
 
 \f
@@ -1320,9 +1320,9 @@ typy_has_key (PyObject *self, PyObject *args)
       const char *t_field_name = field.name ();
 
       if (t_field_name && (strcmp_iw (t_field_name, field_name) == 0))
-	Py_RETURN_TRUE;
+	return py_true ().release ();
     }
-  Py_RETURN_FALSE;
+  return py_false ().release ();
 }
 
 /* Make an iterator object to iterate over keys, values, or items.  */
diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c
index dcf86f7db3d..6bff66849df 100644
--- a/gdb/python/py-unwind.c
+++ b/gdb/python/py-unwind.c
@@ -369,7 +369,7 @@ unwind_infopy_add_saved_register (PyObject *self, PyObject *args, PyObject *kw)
 	     here and True otherwise, but again that might require changes in
 	     user code.  So, handle this with minimal impact for the user, while
 	     improving robustness: silently ignore the register/value pair.  */
-	  Py_RETURN_NONE;
+	  return py_none ().release ();
 	}
     }
   catch (const gdb_exception &except)
@@ -391,7 +391,7 @@ unwind_infopy_add_saved_register (PyObject *self, PyObject *args, PyObject *kw)
   if (!found)
     unwind_info->saved_regs->emplace_back (regnum, std::move (new_value));
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* UnwindInfo cleanup.  */
@@ -516,9 +516,9 @@ pending_framepy_is_valid (PyObject *self, PyObject *args)
   pending_frame_object *pending_frame = (pending_frame_object *) self;
 
   if (pending_frame->frame_info == nullptr)
-    Py_RETURN_FALSE;
+    return py_false ().release ();
 
-  Py_RETURN_TRUE;
+  return py_true ().release ();
 }
 
 /* Implement PendingFrame.name().  Return a string that is the name of the
@@ -549,7 +549,7 @@ pending_framepy_name (PyObject *self, PyObject *args)
     return PyUnicode_Decode (name.get (), strlen (name.get ()),
 			     host_charset (), nullptr);
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Implement gdb.PendingFrame.pc().  Returns an integer containing the
@@ -693,7 +693,7 @@ pending_framepy_function (PyObject *self, PyObject *args)
   if (sym != nullptr)
     return symbol_to_symbol_object (sym).release ();
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Implementation of
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index a5b2303728c..9443d0ed8c9 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -915,7 +915,7 @@ valpy_assign (PyObject *self_obj, PyObject *args)
   if (!valpy_assign_core (self, val))
     return nullptr;
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 static Py_ssize_t
@@ -1284,9 +1284,9 @@ valpy_get_is_optimized_out (PyObject *self, void *closure)
     }
 
   if (opt)
-    Py_RETURN_TRUE;
+    return py_true ().release ();
 
-  Py_RETURN_FALSE;
+  return py_false ().release ();
 }
 
 /* Implements gdb.Value.is_unavailable.  Return true if any part of the
@@ -1308,9 +1308,9 @@ valpy_get_is_unavailable (PyObject *self, void *closure)
     }
 
   if (!entirely_available)
-    Py_RETURN_TRUE;
+    return py_true ().release ();
 
-  Py_RETURN_FALSE;
+  return py_false ().release ();
 }
 
 /* Implements gdb.Value.is_lazy.  */
@@ -1330,9 +1330,9 @@ valpy_get_is_lazy (PyObject *self, void *closure)
     }
 
   if (opt)
-    Py_RETURN_TRUE;
+    return py_true ().release ();
 
-  Py_RETURN_FALSE;
+  return py_false ().release ();
 }
 
 /* Get gdb.Value.bytes attribute.  */
@@ -1403,7 +1403,7 @@ valpy_fetch_lazy (PyObject *self, PyObject *args)
       return gdbpy_handle_gdb_exception (nullptr, except);
     }
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Calculate and return the address of the PyObject as the value of
@@ -1830,11 +1830,11 @@ valpy_richcompare (PyObject *self, PyObject *other, int op)
       case Py_LT:
       case Py_LE:
       case Py_EQ:
-	Py_RETURN_FALSE;
+	return py_false ().release ();
       case Py_NE:
       case Py_GT:
       case Py_GE:
-	Py_RETURN_TRUE;
+	return py_true ().release ();
       default:
 	/* Can't happen.  */
 	PyErr_SetString (PyExc_NotImplementedError,
@@ -1856,9 +1856,9 @@ valpy_richcompare (PyObject *self, PyObject *other, int op)
     return NULL;
 
   if (result == 1)
-    Py_RETURN_TRUE;
+    return py_true ().release ();
 
-  Py_RETURN_FALSE;
+  return py_false ().release ();
 }
 
 /* Implements conversion to long.  */
@@ -2186,7 +2186,7 @@ gdbpy_convenience_variable (PyObject *self, PyObject *args)
     }
 
   if (result == nullptr && !found)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   return result.release ();
 }
@@ -2231,7 +2231,7 @@ gdbpy_set_convenience_variable (PyObject *self, PyObject *args)
       return gdbpy_handle_gdb_exception (nullptr, except);
     }
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Returns 1 in OBJ is a gdb.Value object, 0 otherwise.  */
diff --git a/gdb/python/py-xmethods.c b/gdb/python/py-xmethods.c
index 24c8f48e1bd..673cf6e0769 100644
--- a/gdb/python/py-xmethods.c
+++ b/gdb/python/py-xmethods.c
@@ -94,7 +94,7 @@ invoke_match_method (PyObject *matcher, PyObject *py_obj_type,
   if (enabled == 0)
     {
       /* Return 'None' if the matcher is not enabled.  */
-      Py_RETURN_NONE;
+      return py_none ().release ();
     }
 
   gdbpy_ref<> match_method (PyObject_GetAttrString (matcher,
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 502fe682b2c..5ddfd4e4945 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -521,9 +521,9 @@ gdbpy_parameter_value (const setting &var)
     case var_boolean:
       {
 	if (var.get<bool> ())
-	  Py_RETURN_TRUE;
+	  return py_true ().release ();
 	else
-	  Py_RETURN_FALSE;
+	  return py_false ().release ();
       }
 
     case var_auto_boolean:
@@ -531,11 +531,11 @@ gdbpy_parameter_value (const setting &var)
 	enum auto_boolean ab = var.get<enum auto_boolean> ();
 
 	if (ab == AUTO_BOOLEAN_TRUE)
-	  Py_RETURN_TRUE;
+	  return py_true ().release ();
 	else if (ab == AUTO_BOOLEAN_FALSE)
-	  Py_RETURN_FALSE;
+	  return py_false ().release ();
 	else
-	  Py_RETURN_NONE;
+	  return py_none ().release ();
       }
 
     case var_uinteger:
@@ -561,7 +561,7 @@ gdbpy_parameter_value (const setting &var)
 			&& *l->val == -1)
 		      value = -1;
 		    else
-		      Py_RETURN_NONE;
+		      return py_none ().release ();
 		  }
 		else if (l->val.has_value ())
 		  value = *l->val;
@@ -800,7 +800,7 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
   if (to_string)
     return PyUnicode_Decode (to_string_res.c_str (), to_string_res.size (),
 			     host_charset (), nullptr);
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Implementation of Python rbreak command.  Take a REGEX and
@@ -1105,7 +1105,7 @@ static PyObject *
 gdbpy_invalidate_cached_frames (PyObject *self, PyObject *args)
 {
   reinit_frame_cache ();
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Read a file as Python code.
@@ -1194,7 +1194,7 @@ gdbpy_post_event (PyObject *self, PyObject *args)
   gdbpy_event event (std::move (func_ref));
   run_on_main_thread (event);
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Interrupt the current operation on the main thread.  */
@@ -1218,7 +1218,7 @@ gdbpy_interrupt (PyObject *self, PyObject *args)
   }
 #endif
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 \f
@@ -1617,7 +1617,7 @@ gdbpy_write (PyObject *self, PyObject *args, PyObject *kw)
       return gdbpy_handle_gdb_exception (nullptr, except);
     }
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* A python function to flush a gdb stream.  The optional keyword
@@ -1653,7 +1653,7 @@ gdbpy_flush (PyObject *self, PyObject *args, PyObject *kw)
 	gdb_flush (gdb_stdout);
     }
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Implement gdb.warning().  Takes a single text string argument and emit a
@@ -1687,7 +1687,7 @@ gdbpy_warning (PyObject *self, PyObject *args, PyObject *kw)
       return gdbpy_handle_gdb_exception (nullptr, ex);
     }
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 /* Return non-zero if print-stack is not "none".  */
@@ -1860,7 +1860,7 @@ static PyObject *
 gdbpy_get_current_objfile (PyObject *unused1, PyObject *unused2)
 {
   if (! gdbpy_current_objfile)
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   return objfile_to_objfile_object (gdbpy_current_objfile).release ();
 }
-- 
2.51.0


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

* Re: [PATCH v2 1/2] [gdb/python] Introduce py_none/py_true/py_false functions
  2026-05-13 16:30 ` [PATCH v2 1/2] [gdb/python] Introduce py_none/py_true/py_false functions Tom de Vries
@ 2026-05-14 17:46   ` Tom Tromey
  2026-05-15 10:53     ` Tom de Vries
  0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2026-05-14 17:46 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> +/* The following three functions are refcount-safe wrappers around
Tom> +   Py_RETURN_{NONE,TRUE,FALSE}.  Starting with python 3.12, None, True and
Tom> +   False are immortal, and increasing and decreasing refcount for such object
Tom> +   is a no-op, but while supporting older versions we ignore that aspect
Tom> +   here.  */

This comment is mildly incorrect in that using gdbpy_ref<> inherently
implies a decref.  Immortality of Python objects isn't really a concern
at the API level.  It's an implementation detail of the Python
interpreter.

The rest of the patch seems ok to me.  I'm not a huge fan of
immediately-evaluated lambdas but OTOH it's probably harmless here.

    +  return gdbpy_ref<> ([] { Py_RETURN_FALSE; } ());
    +}
     #endif /* GDB_PYTHON_PYTHON_INTERNAL_H */

Newline between the closing brace and the #endif please.

thanks,
Tom

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

* Re: [PATCH v2 2/2] [gdb/python] Remove Py_RETURN_{NONE,TRUE,FALSE}
  2026-05-13 16:30 ` [PATCH v2 2/2] [gdb/python] Remove Py_RETURN_{NONE,TRUE,FALSE} Tom de Vries
@ 2026-05-14 17:47   ` Tom Tromey
  0 siblings, 0 replies; 6+ messages in thread
From: Tom Tromey @ 2026-05-14 17:47 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> Result of:
Tom> ...
Tom> $ sed -i 's/Py_RETURN_NONE/return py_none ().release ()/' gdb/python/*.{c,h}
Tom> ...
Tom> with the changes in py_none reverted.

Tom> Likewise for Py_RETURN_TRUE and Py_RETURN_FALSE.

Ok.
Approved-By: Tom Tromey <tom@tromey.com>

Tom

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

* Re: [PATCH v2 1/2] [gdb/python] Introduce py_none/py_true/py_false functions
  2026-05-14 17:46   ` Tom Tromey
@ 2026-05-15 10:53     ` Tom de Vries
  0 siblings, 0 replies; 6+ messages in thread
From: Tom de Vries @ 2026-05-15 10:53 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 5/14/26 7:46 PM, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
> 
> Tom> +/* The following three functions are refcount-safe wrappers around
> Tom> +   Py_RETURN_{NONE,TRUE,FALSE}.  Starting with python 3.12, None, True and
> Tom> +   False are immortal, and increasing and decreasing refcount for such object
> Tom> +   is a no-op, but while supporting older versions we ignore that aspect
> Tom> +   here.  */
> 
> This comment is mildly incorrect in that using gdbpy_ref<> inherently
> implies a decref.  Immortality of Python objects isn't really a concern
> at the API level.  It's an implementation detail of the Python
> interpreter.
> 

Hi Tom,

thank for the review.

I'm not 100% sure I understand what is mildly incorrect here.  In a v3 
(to be submitted soonish), I've expanded the comment a bit, so hopefully 
it'll be either correct, or it'll be easier to point out which bit is 
incorrect.

> The rest of the patch seems ok to me.  I'm not a huge fan of
> immediately-evaluated lambdas but OTOH it's probably harmless here.
> 

I've fixed that in the v3.

>      +  return gdbpy_ref<> ([] { Py_RETURN_FALSE; } ());
>      +}
>       #endif /* GDB_PYTHON_PYTHON_INTERNAL_H */
> 
> Newline between the closing brace and the #endif please.
> 

Fixed in the v3.

Thanks,
- Tom

> thanks,
> Tom


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

end of thread, other threads:[~2026-05-15 10:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-13 16:30 [PATCH v2 0/2] [gdb/python] Remove Py_RETURN_{NONE,TRUE,FALSE} Tom de Vries
2026-05-13 16:30 ` [PATCH v2 1/2] [gdb/python] Introduce py_none/py_true/py_false functions Tom de Vries
2026-05-14 17:46   ` Tom Tromey
2026-05-15 10:53     ` Tom de Vries
2026-05-13 16:30 ` [PATCH v2 2/2] [gdb/python] Remove Py_RETURN_{NONE,TRUE,FALSE} Tom de Vries
2026-05-14 17:47   ` Tom Tromey

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