Re: [PATCH v2 6/9] gdb/python: flatten functions calling PyObject_New and use gdbpy_ref

Matthieu Longo
2026-03-09T11:42:48Z

On 03/03/2026 18:22, Tom Tromey wrote:
>>>>>> Matthieu Longo <matthieu.longo@arm.com> writes:
>
>> This patch aims at systematically using gdbpy_ref<> at all call sites
>> of PyObject_New(). This prepares for future patches that expect
>> gdbby_ref<> parameters and affect return handling.
>> As part of this change, flattening the affected functions so that the
>> return logic becomes clearer and more flexible to adjust.
>
> Makes sense, thank you.
>
>> - return gdbpy_ref<>::new_reference (result);
>> + return gdbpy_ref<>::new_reference (object.release ());
>
> If that other series goes in the '.release' can be dropped.
>
> Tom

As explained in the previous patch, because we still need to account for the reference hold by the registry.

Matthieu