From 7fc4f93e286e4222e03e16491459fdaeeee210be Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 20 Feb 2026 13:34:45 -0700 Subject: Return gdbpy_ref<> from gdbpy_registry::lookup This changes gdbpy_registry::lookup to return a gdbpy_ref<>, using the type system to convey that a new reference is always returned. Approved-By: Simon Marchi --- gdb/python/python-internal.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'gdb/python/python-internal.h') diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 1f0964f24d3..fdd353ffbeb 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -1191,14 +1191,13 @@ public: } /* Lookup pre-existing Python object for given VAL. Return such object - if found, otherwise return NULL. This method always returns new - reference. */ + if found, otherwise return NULL. */ template - obj_type *lookup (O *owner, val_type *val) const + gdbpy_ref<> lookup (O *owner, val_type *val) const { obj_type *obj = get_storage (owner)->lookup (val); Py_XINCREF (static_cast (obj)); - return obj; + return gdbpy_ref<> (obj); } private: -- cgit v1.2.3