[docs] [issue12902] help("modules") executes module code

Dev Player report at bugs.python.org
Fri Jul 11 05:46:15 CEST 2014

Dev Player added the comment:

Mentioned for informational purposes only.

I too experience the running of external packages with a different library when doing help('modules') in the interpreter. This is a fresh install of Python 3.4 on WinXP.

The text I get in the python.exe interpreter is:
"Expected Tk Togl installation in C:\Python\Python34\lib\site-packages\OpenGl\Tk\togl-win32"

Then I get an empty TK popup window.

Although this other issue was ages ago and was with a different machine, Python version and set of libraries I'm giving reference to this only because of mention of help(). http://bugs.python.org/issue10060

Although there is a command line option to prevent the import of site, while I may not want "help" to be imported, I usually want "site" to be imported. It would be nice to exclude the "help" import only via a command line.

I wonder if the interpreter could be given a command line option just to parse modules/scripts/packages/librarys to only compile the lines containing def and class without anything within the namespace except implicitly declared docstrings  (it not __doc__ = """...""")

In other words if you had source like:
def somefunc(arg=None):
   """here is the func __doc__"""
   x = value

the interpreter could basically compile that into:

def somefunc(arg-None):
    """here is the func __doc__"""
    return None

or perhaps shortcircuit any non def/class/ """ """ to be tokenized as the pass statement would be.

Those would be feature/enhance kind thing I suppose.

nosy: +devplayer

Python tracker <report at bugs.python.org>

More information about the docs mailing list