when a module being loaded is interrupted by an exception, code blocks that have the module's scope in their environment will later evaluate variables bound to that module to None, instead of preserving that scope (because it is still referenced somewhere) or raising a NameError (for which i see no reason, but which would still be better than silently returning None).
this can happen, for example, when one tries to join different programs in one main loop by having the modules first hook up to events and then terminating the subprograms by replacing the call to the main loop with an exception raiser. attached, there is a tarball with two similar examples, one demonstrating that with functions instead of modules (this behaves as expected; ./function/), the other showing that when a module's block is terminated, the remaining variables are set to None (./module/); both can be run by calling `python main.py` in the respective directory. * is this a bug in the pythin implementation? (i've tested it both with 2.5 and with 3.0b2) * if yes, is it identical to [1748015]? (i suppose it is, but lacking experience with pdb i am not sure) * can / will this be fixed? * 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) answers to any of these questions would be very much appreciated regards chrysn [1748015] http://bugs.python.org/issue1748015 -- To use raw power is to make yourself infinitely vulnerable to greater powers. -- Bene Gesserit axiom
module_none.tar.bz2
Description: Binary data
signature.asc
Description: Digital signature
-- http://mail.python.org/mailman/listinfo/python-list