Re: [PATCH v3 0/4] Python safety initial work

Tom de Vries <[email protected]>
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
On 8/7/26 9:48 PM, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <[email protected]> writes:
> 
> Tom> I found this code:
> Tom> ...
> Tom>       /* Note this returns a borrowed reference.  */
> Tom>       PyObject *arg = PyTuple_GetItem (args, i);
> Tom> ...
> Tom> and decided to try to convert all PyTuple_GetItem calls.  The result
> Tom> of that exercise is attached.
> 
> Tom> I ended up also touching the wrapper function:
> Tom> ...
> Tom>  static inline gdbpy_borrowed_ref<>
> Tom>  gdbpy_tuple_get_item (gdbpy_borrowed_ref<> tuple, Py_ssize_t pos)
> Tom>  {
> Tom> -  PyObject *result = PyTuple_GetItem (tuple, pos);
> Tom> +  gdbpy_opt_borrowed_ref<> result = PyTuple_GetItem (tuple, pos);
> Tom>    if (result == nullptr)
> Tom>      throw gdb_python_exception ();
> Tom> -  return result;
> Tom> +  return (PyObject *)result;
> Tom>  }
> Tom> ...
> Tom> but perhaps you left that out intentionally?
> 
> Yeah, in this spot it didn't seem to really be necessary.
> The idea of the wrapper file is to eventually isolate all "raw" calls to
> the Python API.
> 
> Tom> I haven't used the gdbpy_tuple_get_item wrapper, AFAICT it was not
> Tom> applicable.
> 
> The long term goal is to convert everything to call the wrappers.
> This way exception handling will be enforced.

Ok, I've started over and converted valpy_call, now indeed using 
gdbpy_tuple_get_item.

Thanks,
- Tom
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.