From: Doug Evans <dje@google.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] python(+solib error): save/restore error state
Date: Fri, 08 Oct 2010 20:20:00 -0000 [thread overview]
Message-ID: <AANLkTik2LAWLernit41v_bnt-JDK=QwMPJU4AejehKVh@mail.gmail.com> (raw)
In-Reply-To: <AANLkTimBuC_3L77K-=HjKu9wq0SdipsRa4b4XsONcbe2@mail.gmail.com>
On Fri, Oct 8, 2010 at 1:08 PM, Doug Evans <dje@google.com> wrote:
> On Fri, Oct 8, 2010 at 12:11 PM, Jan Kratochvil
> <jan.kratochvil@redhat.com> wrote:
>> @@ -768,6 +782,13 @@ source_python_script_for_objfile (struct objfile *objfile,
>> clear the error indicator. */
>> PyRun_SimpleFile (stream, file);
>>
>> + if (PyErr_Occurred ())
>> + {
>> + gdbpy_print_stack ();
>> + error (_("Error reading python script %s for object file %s"), file,
>> + objfile->name);
>> + }
>> +
>> do_cleanups (cleanups);
>> gdbpy_current_objfile = NULL;
>> }
>
> Hi. Most of the patch seems great, but it raises a question that I
> think needs to be answered.
>
> The comment above this code says:
>
> /* Note: If an exception occurs python will print the traceback and
> clear the error indicator. */
>
> ISTM that either this comment is wrong or the above patch is wrong, or
> some combination thereof.
>
> Also, if there is a problem here, then presumably source_python_script
> has the same problem, but I don't see it addressed in this patch.
>
> Plus if PyRun_SimpleFile can leave an outstanding error, we should
> research whether PyRun_SimpleString has the same problem. I see
> python.c checks the result of PyRun_SimpleString and calls
> gdbpy_print_stack if there's an error. Except that the python docs
> say there is no way to get the error.
>
> ref: http://docs.python.org/c-api/veryhigh.html?highlight=pyrun_simplestring#PyRun_SimpleString
>
> The docs for PyRun_SimpleFile suggest the same, there is no way to get
> the error.
>
> So, am I misreading the python docs or do we need the above patch?
> (and then if not, do we need the calls to gdbpy_print_stack after the
> calls to PyRun_SimpleString? Some experiments are in order - off to do
> some ...
>
Better yet, "use the source Luke ..." 1/2 :-).
Looking at the sources for PyRun_SimpleFile, I see PyErr_Print being
called before -1 is returned.
Similarly for PyRun_SimpleString.
Am I missing something?
next prev parent reply other threads:[~2010-10-08 20:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-08 19:12 Jan Kratochvil
2010-10-08 20:08 ` Doug Evans
2010-10-08 20:20 ` Doug Evans [this message]
2010-10-08 21:27 ` Tom Tromey
2010-10-08 21:35 ` Doug Evans
2010-10-09 20:40 ` [patch] python: save/restore/fix " Jan Kratochvil
2010-10-12 19:55 ` Tom Tromey
2010-10-12 21:08 ` Jan Kratochvil
2010-10-12 21:39 ` Tom Tromey
2010-10-13 13:28 ` Jan Kratochvil
2010-10-13 15:38 ` Tom Tromey
2010-10-13 15:58 ` Jan Kratochvil
2010-10-13 18:46 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='AANLkTik2LAWLernit41v_bnt-JDK=QwMPJU4AejehKVh@mail.gmail.com' \
--to=dje@google.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox