]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/python] Remove Py_RETURN_{NONE,TRUE,FALSE,NOTIMPLEMENTED}
authorTom de Vries <tdevries@suse.de>
Fri, 15 May 2026 19:38:12 +0000 (21:38 +0200)
committerTom de Vries <tdevries@suse.de>
Fri, 15 May 2026 19:38:12 +0000 (21:38 +0200)
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,Py_RETURN_FALSE and Py_RETURN_NOTIMPLEMENTED.

Approved-By: Tom Tromey <tom@tromey.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34145

29 files changed:
gdb/python/py-block.c
gdb/python/py-breakpoint.c
gdb/python/py-cmd.c
gdb/python/py-connection.c
gdb/python/py-corefile.c
gdb/python/py-disasm.c
gdb/python/py-evtregistry.c
gdb/python/py-finishbreakpoint.c
gdb/python/py-frame.c
gdb/python/py-framefilter.c
gdb/python/py-inferior.c
gdb/python/py-infthread.c
gdb/python/py-linetable.c
gdb/python/py-mi.c
gdb/python/py-micmd.c
gdb/python/py-objfile.c
gdb/python/py-prettyprint.c
gdb/python/py-progspace.c
gdb/python/py-record-btrace.c
gdb/python/py-record.c
gdb/python/py-registers.c
gdb/python/py-symbol.c
gdb/python/py-symtab.c
gdb/python/py-tui.c
gdb/python/py-type.c
gdb/python/py-unwind.c
gdb/python/py-value.c
gdb/python/py-xmethods.c
gdb/python/python.c

index d9751d26378a253ac4a982c0fbb29e5c6128185f..17c9cbdaff0eec296bf77c4b148435fc51bca1e4 100644 (file)
@@ -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.  */
index d96c67694b3e96053503b3b1f22b0f4249081497..68d4f77c608357f6a5a8a1147cef70800f883e27 100644 (file)
@@ -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.  */
index 3fbc26b0cdec5c752083a894abc5181c0269485a..bcb1ba37d93d929240937f41cc7d88c573ef807e 100644 (file)
@@ -76,7 +76,7 @@ static PyObject *
 cmdpy_dont_repeat (PyObject *self, PyObject *args)
 {
   dont_repeat ();
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 \f
index a8bea4d832fe91382478282742483529cf0123a9..2d0b2e94659cb5e65779fb18e5a182620744eb2a 100644 (file)
@@ -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.  */
index 0fa4e90488cedd238744969df3712c567df234fd..2c5596d093c84ff45a0af0d2f99c1b7d5098d54f 100644 (file)
@@ -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
index 1c5661dd307814c3c8c2b67e0932a708bc01f853..d4d50e90035c4b7918ab2436e34f2ad5b751fe36 100644 (file)
@@ -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
index 9d12d0161f15674d629be7fc8bd5ec51e5b7bacb..8d2a68da2a4c025fb3c58f6b1205215f7e775628 100644 (file)
@@ -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
index fbbb705a864c59b27cf93d41c3ae6af9ba061625..f85f4fff766d05c99cbbd27d947ee795cecf7db2 100644 (file)
@@ -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;
index 1420d2ac5b9fbe29542b023bf4bf99698c504d23..2a674ba52f83440e86eb8c6088f51cec6639f879 100644 (file)
@@ -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.  */
index 26172d9f80e2d05d04ef913e4b6b47b16df54e76..f256a26807c4150fddf978ef21d48b546f85afbc 100644 (file)
@@ -279,7 +279,7 @@ get_py_iter_from_func (PyObject *filter, const char *func)
        }
     }
   else
-    Py_RETURN_NONE;
+    return py_none ().release ();
 
   return NULL;
 }
index 1a30f4ee3784aeebc4fb39c8ccf7902180771e31..d2fc159c227c683588872d5e9390b71165b6ce3d 100644 (file)
@@ -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 ();
 }
index 672546e106d1b631d04a18942aa77d64cafb8089..ddb67a284aceda0b4c3e925a30ff1c3260a87ed1 100644 (file)
@@ -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
index 2afa9b033e7784be7b1559b1d10cdcf8d640feec..d2d85026a321a4b3fbe3586bb0e03a059dccd9c5 100644 (file)
@@ -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);
index 27c79d6063681df6c78a2c057ff19f83df8b9af1..1bcb276da8a18039de4b544d520322077c795de0 100644 (file)
@@ -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 ();
 }
index 6edea04ccb5fb31a28c22978ca84b2ead292302c..73f5297bd70d122dda31c8922151731fa325f7cd 100644 (file)
@@ -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
index d427f14942931ae3f1509db94c9e2cc1d4fdb57f..ec8b82fbe133ee95aeff6d1de43fc0e50d4edbc3 100644 (file)
@@ -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 ();
     }
index 0cf0cde881c4f4874f04c7de1a62074d026fe7ff..a561196a2a9fcd9c6e357543b7e429f328e4c3a6 100644 (file)
@@ -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.
index 37b92a64634c071f350a32bbcdd023f7f82077b5..48e52328e9c03699cf73da39945810d0e007f5e6 100644 (file)
@@ -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
index 6026de91e678b6d748cdd440043ac57fd7301e64..5f1c93170c65ddc5ea44330c0236396fdd96d4e3 100644 (file)
@@ -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.  */
index 294da0725e10e10d241bc35c06f116deea326804..753826f88c4e8b22a1cbed181123329615c47e96 100644 (file)
@@ -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);
index c6e0748e935d04b50437a6c826c52c7678d6fcef..14cf19a6e66f5ac5df2c4886dc9c2d2d933056e3 100644 (file)
@@ -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.  */
index 6293b658ea1dbf43ee539dff3c6f9409350fa28c..bf803a3b4872726aeb8b0dd7aaf96bedde7d5ba6 100644 (file)
@@ -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
index c5e18543740fe326b78ea94a18e9f7704f0704fc..f1fbfa58d652588f1abc43080b41067823fc92e8 100644 (file)
@@ -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
index be19193770fde17a8be34d1cc7702cb593bf339f..111e0f4c9e3a7516a45c5c4a38287f1de3b16de6 100644 (file)
@@ -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.  */
index 263d48a93650a9cc935d24623598f1ce7ab3ee14..89ff19cd7592150f43f5ef2fff92fd675f8e8a7f 100644 (file)
@@ -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.  */
index dcf86f7db3d7331849e7245c5f4cb1d566b30493..6bff66849dfffb3eb034340dcee390d11c44857f 100644 (file)
@@ -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
index a5b2303728c82a91299fa01e5449bf14b7c6ed2d..9443d0ed8c9dc3cd3bf95450f20c4adac5dbacfb 100644 (file)
@@ -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.  */
index 24c8f48e1bd889f3d796ea08e07444215fe55d5c..673cf6e07699db52e632cbaf285a23d14a918216 100644 (file)
@@ -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,
index 045626b70fd45fba48f1ba602b3a599b17aa337e..4644d2868556d76d042a9446bff442d13788ded7 100644 (file)
@@ -522,9 +522,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:
@@ -532,11 +532,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:
@@ -562,7 +562,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;
@@ -801,7 +801,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
@@ -1106,7 +1106,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.
@@ -1195,7 +1195,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.  */
@@ -1219,7 +1219,7 @@ gdbpy_interrupt (PyObject *self, PyObject *args)
   }
 #endif
 
-  Py_RETURN_NONE;
+  return py_none ().release ();
 }
 
 \f
@@ -1618,7 +1618,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
@@ -1654,7 +1654,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
@@ -1688,7 +1688,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".  */
@@ -1861,7 +1861,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 ();
 }