This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix Python completion when using the "complete" command
- From: Doug Evans <dje at google dot com>
- To: Sergio Durigan Junior <sergiodj at redhat dot com>
- Cc: Keith Seitz <keiths at redhat dot com>, GDB Patches <gdb-patches at sourceware dot org>
- Date: Wed, 8 Apr 2015 13:39:13 -0700
- Subject: Re: [PATCH] Fix Python completion when using the "complete" command
- Authentication-results: sourceware.org; auth=none
- References: <87d23ovk55 dot fsf at redhat dot com> <87ego4txco dot fsf at redhat dot com> <87vbh74uqd dot fsf at redhat dot com> <55257877 dot 3040604 at redhat dot com> <87384a1jeo dot fsf at redhat dot com>
Sergio Durigan Junior writes:
> On Wednesday, April 08 2015, Keith Seitz wrote:
>
> >>> >+ This function is usually called twice: one when we are figuring out
> >
> > nitpick (sorry): "once" instead of "one"
>
> Thanks, fixed.
>
> > This looks good to me.
> >
> > I have applied this patch to my completer branch, and I can verify
> > that it fixes the (other) completion problems I've seen. I recommend
> > that a maintainer approve this.
>
> Thanks for the review, Keith!
>
> Here is the updated patch + ChangeLog entry.
>
> --
> Sergio
> GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36
> Please send encrypted e-mail if possible
> http://sergiodj.net/
>
> gdb/ChangeLog:
> 2015-04-08 Sergio Durigan Junior <sergiodj@redhat.com>
>
> PR python/16699
> * python/py-cmd.c (cmdpy_completer_helper): Adjust function to not
> use a caching mechanism. Adjust comments and code to reflect
> that. Replace 'sizeof' by 'strlen' when fetching 'wordobj'.
> (cmdpy_completer_handle_brkchars): Adjust call to
> cmdpy_completer_helper. Call Py_XDECREF for 'resultobj'.
> (cmdpy_completer): Likewise.
>
> gdb/testsuite/ChangeLog:
> 2015-04-08 Keith Seitz <keiths@redhat.com>
>
> PR python/16699
> * gdb.python/py-completion.exp: New tests for completion.
> * gdb.python/py-completion.py (CompleteLimit1): New class.
> (CompleteLimit2): Likewise.
> (CompleteLimit3): Likewise.
> (CompleteLimit4): Likewise.
> (CompleteLimit5): Likewise.
> (CompleteLimit6): Likewise.
> (CompleteLimit7): Likewise.
LGTM.
One comment below.
> + resultobj = PyObject_CallMethodObjArgs ((PyObject *) obj, complete_cst,
> + textobj, wordobj, NULL);
> + Py_DECREF (textobj);
> + Py_DECREF (wordobj);
> + if (!resultobj)
> + {
> + /* Just swallow errors here. */
> + PyErr_Clear ();
> }
I realize this is just copying the previous code,
but does swallowing errors here make it hard to debug problems
in the completer function?
Is this something we want to address in a future patch?