Message133482
Following Nick's advice, I extended runpy.run_module to accept an extra parameter to be used as replacement __main__ namespace.
Having this, I can make this temporary __main__ accessible in main() in modules like trace/profile/pdb even if module execution fails with an exception. The problem is that it's visible only in the calling function but not in the global namespace. One way to make it accessible for post mortem debugging would be to create the replacement __main__ module in the global namespace and then pass as a parameter to main(), but this seems clumsy.
So maybe the way to go is to have runpy store last used __main__, sys.exc_info() style. In this case, would this be the correct way to store it in runpy:
try:
import threading
except ImportError:
temp_main = None
else:
local_storage = threading.local()
local_storage.temp_main = None
temp_main = local_storage.temp_main
? |
|
Date |
User |
Action |
Args |
2011-04-10 21:27:00 | Greg.Slodkowicz | set | recipients:
+ Greg.Slodkowicz, georg.brandl, terry.reedy, ncoghlan, belopolsky, giampaolo.rodola, eli.bendersky |
2011-04-10 21:27:00 | Greg.Slodkowicz | set | messageid: <1302470820.25.0.448483964544.issue9325@psf.upfronthosting.co.za> |
2011-04-10 21:26:55 | Greg.Slodkowicz | link | issue9325 messages |
2011-04-10 21:26:55 | Greg.Slodkowicz | create | |
|