Re: Make the "python" command resemble the standard Python interpreter

Khoo Yit Phang
2012-01-11T18:48:25Z

Hi,

On Jan 11, 2012, at 1:31 PM, Kevin Pouget wrote:

> On Wed, Jan 11, 2012 at 4:53 PM, Khoo Yit Phang <khooyp@cs.umd.edu> wrote:
>
>>>> + p = command_line_input (prompt, 0, "python");
>>>> + do_cleanups (cleanup);
>>>> + }
>>>
>>> I'm not sure about that, but isn't the clean up supposed to be
>>> executed even if an exception is thrown? it seems not to be the case
>>> here
>>
>> Are you referring to do_cleanups? If I understand correctly, it's to handle the case where an exception is not thrown (see, e.g., py-value.c).
>
> I think that's you're supposed to use the cleanup machinery when you
> don't explicitely handle the exception. Here you code looks like:
>
>> TRY_CATCH
>> {
>> do_something_dangerous()
>> }
>> handle_exception_if_any()
>> continue_anyway()
>
> so I think it's safe to simply call "gdbpy_suspend_sigint_handler"
> after the exception handling.

I don't think that's right. I traced this, and the cleanup function isn't called if I don't use do_cleanup. In this case, it must be called to restore the SIGINT handler to Python. In many other places I've looked that use TRY_CATCH, do_cleanup is called at the end too.

Yit
January 11, 2012