On Tue, Feb 24, 2009 at 03:27:19PM +0100, chr...@fsfe.org wrote: > * is there a workaround? > * especially, is there a workaround that works w/o rewriting the > modules that raise the exceptions? (otherwise, wrapping all the > stuff called in the __name__=="__main__" wrapper into a main() > function and then calling that would trivially solve that)
update: i've found one, but this only works if the exception is raised at a point determined by the outside. to explain why this is applicable: in the examples, i used `1/0` to raise a zero division exception inside the module whose scope i want to preserve. in my practical application, the exception is thrown by a function that was previously prepared by the outside module and monkey patched to where the inner module is expected to call a method from (in my case, the gtk main loop). now if the function raising the exception saves both `sys._getframe().f_back.f_globals` and a .copy() of that dictionary, the original dictionary can later (when the exception is caught and the module's globals are all None) be .update()d with the copy, and the original module globals are restored. as said, this is just a workaround -- the original question still remains open. regards chrysn -- To use raw power is to make yourself infinitely vulnerable to greater powers. -- Bene Gesserit axiom
signature.asc
Description: Digital signature
-- http://mail.python.org/mailman/listinfo/python-list