> > > > > 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.