mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-05-28 14:08:09 +08:00
gdb/python: convert gdbpy_err_fetch to use gdbpy_ref
Convert the gdbpy_err_fetch class to make use of gdbpy_ref, this removes the need for manual reference count management, and allows the destructor to be removed. There should be no functional change after this commit. I think this cleanup is worth doing on its own, however, in a later commit I will want to copy instances of gdbpy_err_fetch, and switching to using gdbpy_ref means that I can rely on the default copy constructor, without having to add one that handles the reference counts, so this is good preparation for that upcoming change.
This commit is contained in:
@ -194,10 +194,10 @@ gdbpy_err_fetch::to_string () const
|
||||
Using str (aka PyObject_Str) will fetch the error message from
|
||||
gdb.GdbError ("message"). */
|
||||
|
||||
if (m_error_value && m_error_value != Py_None)
|
||||
return gdbpy_obj_to_string (m_error_value);
|
||||
if (m_error_value.get () != nullptr && m_error_value.get () != Py_None)
|
||||
return gdbpy_obj_to_string (m_error_value.get ());
|
||||
else
|
||||
return gdbpy_obj_to_string (m_error_type);
|
||||
return gdbpy_obj_to_string (m_error_type.get ());
|
||||
}
|
||||
|
||||
/* See python-internal.h. */
|
||||
@ -205,7 +205,7 @@ gdbpy_err_fetch::to_string () const
|
||||
gdb::unique_xmalloc_ptr<char>
|
||||
gdbpy_err_fetch::type_to_string () const
|
||||
{
|
||||
return gdbpy_obj_to_string (m_error_type);
|
||||
return gdbpy_obj_to_string (m_error_type.get ());
|
||||
}
|
||||
|
||||
/* Convert a GDB exception to the appropriate Python exception.
|
||||
|
Reference in New Issue
Block a user