Here's what I tried before. I just tried it now and got
exactly the same thing:
(tnb2d@henson) /uf16/tnb2d $ python
Python 1.0.1 (Mar 5 1994)
Copyright 1991-1994 Stichting Mathematisch Centrum, Amsterdam
>>> import sys
>>> print sys.modules
{'__builtin__': <module '__builtin__'>, 'sys': <module 'sys'>, '__main__': <module '__main__'>}
>>> del sys.modules['sys']
>>> print sys.modules
{'__builtin__': <module '__builtin__'>, '__main__': <module '__main__'>}
>>> import sys
Memory fault
(tnb2d@henson) /uf16/tnb2d $
What I need to do is *reset* the interpreter from *within* the
interpreter. When it was imbedded it was easy enough to replicate the
funcitonality of goaway and initall from pythonrun.c. That was
essentially throwing the interpreter away and starting a new one. But
how can I do that from within the interpreter while still staying in
the interpreter? The sequence of calls that I used before to reset it
is:
doneimport();
err_clear();
initimport();
initbuiltin();
initsys();
setpythonpath(getpythonpath());
initintr();
object* m = add_module("__main__");
The first two are from goaway and the last five are from initall, I'm
not sure where the add_module line comes from. I'm starting to think
that I may be able to just stick these all in a function and call it
from within python without completely trashing myself. It's at least
worth a shot.
-------> Tommy.
"Subvert the parental paradigm - Refuse Birth."