From: Tom de Vries Date: Fri, 15 May 2026 19:38:12 +0000 (+0200) Subject: [gdb/python] Remove Py_RETURN_{NONE,TRUE,FALSE,NOTIMPLEMENTED} X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=723d7c3db7b3ed276c040c8d99d77419bc1e591e;p=thirdparty%2Fbinutils-gdb.git [gdb/python] Remove Py_RETURN_{NONE,TRUE,FALSE,NOTIMPLEMENTED} 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 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34145 --- 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 (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 (); } 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 (); } 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 (); } 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 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 (); } @@ -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 (); } @@ -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 045626b70fd..4644d286855 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -522,9 +522,9 @@ gdbpy_parameter_value (const setting &var) case var_boolean: { if (var.get ()) - 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 (); 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 (); } @@ -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 (); }