On 7/19/26 7:16 PM, Tom Tromey wrote: >>>>>> "Tom" == Tom Tromey writes: > >>>>>> "Tom" == Tom Tromey writes: > Tom> I rewrote my earlier Python safety series to use methods a while back. > Tom> And while I like the result, I got bogged down converting things, so I > Tom> thought I'd send some initial work, with the idea that if this looks > Tom> good, other code can be transformed in pieces. > > Tom> Ping. > > Ping again - any thoughts on this? > > Tom I applied the series and tried to use it. I found this code: ... /* Note this returns a borrowed reference. */ PyObject *arg = PyTuple_GetItem (args, i); ... and decided to try to convert all PyTuple_GetItem calls. The result of that exercise is attached. I ended up also touching the wrapper function: ... static inline gdbpy_borrowed_ref<> gdbpy_tuple_get_item (gdbpy_borrowed_ref<> tuple, Py_ssize_t pos) { - PyObject *result = PyTuple_GetItem (tuple, pos); + gdbpy_opt_borrowed_ref<> result = PyTuple_GetItem (tuple, pos); if (result == nullptr) throw gdb_python_exception (); - return result; + return (PyObject *)result; } ... but perhaps you left that out intentionally? Anyway, having done this exercise, I like the idea of making borrowed refs explicit in a type. I haven't used the gdbpy_tuple_get_item wrapper, AFAICT it was not applicable. Acked-By: Tom de Vries Thanks, - Tom