[PATCH v2 3/9] gdb: switch bytes object helpers to Python limited API equivalents

Matthieu Longo
2026-03-03T16:27:19Z

* PyBytes_AS_STRING -> PyBytes_AsString
* PyBytes_GET_SIZE -> PyBytes_Size

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23830
---
gdb/python/py-prettyprint.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index eb7ac2c048f..3dcb4fba1e4 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -318,8 +318,9 @@ print_string_repr (PyObject *printer, const char *hint,
long length;
struct type *type;

- output = PyBytes_AS_STRING (string.get ());
- length = PyBytes_GET_SIZE (string.get ());
+ output = PyBytes_AsString (string.get ());
+ gdb_assert (output != nullptr);
+ length = PyBytes_Size (string.get ());
type = builtin_type (gdbarch)->builtin_char;

if (hint && !strcmp (hint, "string"))
--
2.53.0