mailRe: Proposed solution to bug #6503.


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by Edward d'Auvergne on August 09, 2006 - 18:26:
> > > > > This avoids fpconst.py and the switch from Numeric to Numpy.  The
> > > > > question is whether to use the RelaxErrors or set some warning?  
Would
> > > > > this be alleviated by Gary's proposal of saving the program state 
just
> > > > > prior to throwing the error?  For example using the function
> > > > > 'self.save()' within 'generic_fns/state.py', printing the error
> > > > > message, then quitting.
> > > >
> > > > Saving state as part of the exception handling is a nice idea, but has
> > > > its limitations. Because the error could be thrown before, during or
> > > > after some change to the program state, the state which is saved will 
be
> > > > undefined and possibly inconsistent. As such a saved state may be of
> > > > limited use to most users. It would be a very valuable tool for
> > > > debugging, though.
> > >
> > > I suppose it will probably leave too many temporary files lying
> > > around.  relax tends to throw errors if you do the slightest thing
> > > wrong.
> >
> > True. One option would be to leave the current behaviour as default, and
> > have an optional debugging mode which would allow for saving of state on
> > exceptions. Another feature which might be modified in debugging mode is
> > the suppression of tracebacks on KeyboardInterupt - it is sometimes nice
> > to know exactly what you have interupted when you are forced to ctrl-c
>
> That's a an idea, dump the state if relax is run with the --debug
> flag.  I'm not sure I follow what you mean with the behaviour of the
> keyboard interrupt?  Do you mean that when ctrl-c is hit when run with
> the --debug flag the program instantly and silently terminates without
> printing the KeyboardInterrupt message?

Not exactly what I mean. If I ctrl-c from within Python, I get a
traceback similar to what I get if an exception is raised (because
KeyboardInterrupt is just another exception as far as Python is
concerned). In relax, when running from a script, KeyboardInterupt is
caught and the traceback is suppressed. The change I suggest is in
prompt/interpreter.py line 341:

except KeyboardInterrupt:
    if Debug:
        raise
    else:
        sys.stderr.write("\nScript execution cancelled.\n")

I used a this hack to workout the location of the infinite loop in the
line-search: ctrl-c when stuck in the loop and the traceback told me
exactly where I was in relax.

That's quite useful, and logical. If you could add that change directly to the 1.2 line it would be appreciated. Don't worry about the 1.3 line yet. It hasn't changed since I created it so just prior to starting work on that line I'll merge all the improvements added to the 1.2 line back into the 1.3 line.

Thanks,

Edward



Related Messages


Powered by MHonArc, Updated Thu Aug 10 10:00:28 2006