[issue9325] Add an option to pdb/trace/profile to run library module as a script
Nick Coghlan
report at bugs.python.org
Tue Sep 21 23:26:21 CEST 2010
Nick Coghlan <ncoghlan at gmail.com> added the comment:
I've thought about this in the past, but never really pursued it due to the question of what to do with the __main__ namespace.
There are three options here:
1. Use runpy.run_module to run the module in a fresh __main__ namespace
2. Use runpy.run_module to run the module under its own name
3. Use runpy._run_module_as_main to run the module in the real __main__ namespace
Option 3 is probably a bad idea (due to the risk of clobbering globals from pdb/trace/profile/doctest/etc) but failing to do it that way creates a difference between the way the actual -m switch works and what these modules will be doing.
That said, I haven't looked closely at what these modules do for ordinary scripts, where much the same problem will already arise. If option 1 is adequate for this purpose, then it shouldn't be that hard to add - it's just that I've never done the investigation to see if it *would* be adequate.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9325>
_______________________________________
More information about the Python-bugs-list
mailing list