This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: pydoc - stall when requesting a list of available modules in the online help utility
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: help("modules") executes module code
View: 12902
Assigned To: Nosy List: Jeroen, ned.deily, pje, roger.serwy, terry.reedy
Priority: normal Keywords:

Created on 2012-02-02 14:29 by Jeroen, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (11)
msg152459 - (view) Author: Jeroen (Jeroen) Date: 2012-02-02 14:45
When using IDLE (2.7.2) in Ubuntu 11.10 the following error occurs:

When the online help utility in IDLE is started (by entering the help()
commando), it should be possible to get a list of all available modules by
typing "modules". When I do so a message is shown that the list will be
created, but after a few seconds the list isn't shown but IDLE is closed
instead.

Python version: Python 2.7.2+ (default, Oct  4 2011, 20:06:09) [GCC 4.6.1]
on linux2
Tk version: 8.5
IDLE version: 2.7.2

2012/2/2 Jeroen <report@bugs.python.org>

>
> Changes by Jeroen <dariojee@gmail.com>:
>
>
> ----------
> components: IDLE
> nosy: Jeroen
> priority: normal
> severity: normal
> status: open
> title: IDLE closes when requesting a list of available modules in the
> online help utility
> type: behavior
> versions: Python 2.7
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue13926>
> _______________________________________
>
msg152470 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2012-02-02 17:42
I tried this and while IDLE didn't crash, it stalled when running with and without a subprocess. I then tried running this from the regular python interpreter and it stalled there as well. This is not a problem with IDLE, but a problem with pydoc itself.

Steps to reproduce:

    >>> help()

    help> modules

    -- stall --

A blank "Tk" window suddenly appeared, which suggested that something loaded Tkinter. Digging deeper, the "help" utility in Lib/pydoc.py loads every single module found on in sys.path in order to get its __doc__ string. This is doing too much work as the purpose of "modules" is to give a list of available modules.

I modified "ModuleScanner" in pydoc.py so that loader.load_module doesn't get called. I set "desc" and "path" do hard-coded strings and now "modules" returns a list very quickly. A blank tkinter window still pops up, however.
msg152472 - (view) Author: PJ Eby (pje) * (Python committer) Date: 2012-02-02 19:18
The problem might be that you're iterating over more than just the top
level; if you look for submodules then the parent package has to be
imported... and that might make that window load, if there's module-level
code in the package __init__ that does that.
msg152484 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2012-02-02 22:54
Should calling "modules" automatically iterate over all submodules or should it return just a list of top level modules?
msg152485 - (view) Author: PJ Eby (pje) * (Python committer) Date: 2012-02-02 23:17
I don't have the code you're talking about in front of me; just wanted to
give you a lead on the likely cause.
msg152486 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2012-02-02 23:28
You're right. The pkgutil.walk_packages method called from ModuleScanner seems to be importing the submodules. I should have said that in the last message.

I'll try to be clearer. What should the correct behavior be when entering "modules" in the interactive help system? This is an open question to anyone.
msg152488 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2012-02-03 00:07
This issue is essentially a duplicate of #12092. For the OP there, the stall happens because something on Gnome pops up a configuration GUI and, I presume, waits for response. I am thinking now that 'modules' is simply a bad idea and should be removed or severely changed to only list and not execute. There is no telling *what* might be on the search path.

I noted there that there are two issues: documenting help() better, and changing the behavior of help('modules') and that there is least a behavior bug. I am only leaving this issue open because of the report of IDLE crashing - which does not happen on Win7, 3.2. I know nothing of how IDLE executes on *nix and whether there is anything that might be done to at least exit more gracefully.

We might make this the 'change code' issue, though if code is change, some of the proposed doc change will become obsolete.
msg152570 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-02-03 23:36
Jeroen, if you try running "help()" from a command-line python2.7, rather than in IDLE, what results do you get?  Most likely, Python will crash there and there should be an exception and traceback printed, in which case the problem has nothing to do with IDLE directly.  Note that there have been some improvements to pydoc's robustness since 2.7.2 was released (for instance, the changes for issue7425 and issue7367).

(Terry, are you sure you meant Issue12092?)
msg152572 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2012-02-04 00:41
digit transposition corrected 12902
msg152609 - (view) Author: Jeroen (Jeroen) Date: 2012-02-04 11:31
Ned,

I've run the "help()" from the command-line as requested and the result was:

Python 2.7.2+ (default, Oct  4 2011, 20:06:09)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> help()

Welcome to Python 2.7!  This is the online help utility.

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://docs.python.org/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, or topics, type "modules",
"keywords", or "topics".  Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as "spam", type "modules spam".

help> modules

Please wait a moment while I gather a list of all available modules...

/usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning:
g_boxed_type_register_static: assertion `g_type_from_name (name) == 0'
failed
  import gobject._gobject
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning:
g_boxed_type_register_static: assertion `g_type_from_name (name) == 0'
failed
  from gtk import _gtk

** (python:2050): CRITICAL **: pyg_register_boxed: assertion `boxed_type !=
0' failed
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning:
cannot register existing type `GdkDevice'
  from gtk import _gtk
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning:
g_type_get_qdata: assertion `node != NULL' failed
  from gtk import _gtk
Segmentation fault

2012/2/4 Ned Deily <report@bugs.python.org>

>
> Ned Deily <nad@acm.org> added the comment:
>
> Jeroen, if you try running "help()" from a command-line python2.7, rather
> than in IDLE, what results do you get?  Most likely, Python will crash
> there and there should be an exception and traceback printed, in which case
> the problem has nothing to do with IDLE directly.  Note that there have
> been some improvements to pydoc's robustness since 2.7.2 was released (for
> instance, the changes for issue7425 and issue7367).
>
> (Terry, are you sure you meant Issue12092?)
>
> ----------
> nosy: +ned.deily
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue13926>
> _______________________________________
>
msg152632 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-02-04 16:22
Thanks for the additional output.  It demonstrates that the problem you've encountered is an old known issue with pydoc help when there are modules that cause exceptions upon importing.  And the additional issue Roger brought up is also due to pydoc importing modules.  Neither of these is specific to IDLE environments.  There are a number of open duplicate and/or closely related issues on the bug tracker, including #12901, #10060, and #11995.  Let's move further discussion to one of those.
History
Date User Action Args
2022-04-11 14:57:26adminsetgithub: 58134
2013-10-29 17:48:42ned.deilylinkissue19436 superseder
2012-02-04 16:22:32ned.deilysetstatus: open -> closed
resolution: duplicate
messages: + msg152632

stage: resolved
2012-02-04 11:31:44Jeroensetmessages: + msg152609
2012-02-04 00:41:49terry.reedysetmessages: + msg152572
2012-02-04 00:39:58terry.reedysetsuperseder: Clarify sentence in tutorial -> help("modules") executes module code
2012-02-03 23:36:11ned.deilysetnosy: + ned.deily
messages: + msg152570
2012-02-03 00:07:57terry.reedysetsuperseder: Clarify sentence in tutorial
messages: + msg152488
2012-02-02 23:28:45roger.serwysetmessages: + msg152486
2012-02-02 23:17:34pjesetmessages: + msg152485
2012-02-02 22:54:22roger.serwysetmessages: + msg152484
2012-02-02 19:18:16pjesetmessages: + msg152472
2012-02-02 17:42:58roger.serwysettitle: IDLE closes when requesting a list of available modules in the online help utility -> pydoc - stall when requesting a list of available modules in the online help utility
nosy: + terry.reedy, pje, roger.serwy

messages: + msg152470

components: + Library (Lib), - IDLE
2012-02-02 14:45:30Jeroensetmessages: + msg152459
2012-02-02 14:29:29Jeroencreate