Author okopnik
Recipients okopnik
Date 2011-04-24.03:34:51
SpamBayes Score 2.37227e-12
Marked as misclassified No
Message-id <>
Long-standing problem (happens in every Python version I've tested). The usual situation is when invoking Python (and then "help('modules')") or "pydoc modules" in /tmp, but also happens when located anywhere with unreadable subdirs:

ben@Jotunheim:~$ mkdir /tmp/foo; cd /tmp/foo
ben@Jotunheim:/tmp/foo$ mkdir bar; sudo chmod 000 bar
[sudo] password for ben: 
ben@Jotunheim:/tmp/foo$ pydoc modules

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

Traceback (most recent call last):
  File "/usr/bin/pydoc2.6", line 5, in <module>
  File "/usr/lib/python2.6/", line 2309, in cli
  File "/usr/lib/python2.6/", line 1765, in help
    elif request == 'modules': self.listmodules()
  File "/usr/lib/python2.6/", line 1886, in listmodules
    ModuleScanner().run(callback, onerror=onerror)
  File "/usr/lib/python2.6/", line 1937, in run
    for importer, modname, ispkg in pkgutil.walk_packages(onerror=onerror):
  File "/usr/lib/python2.6/", line 105, in walk_packages
    for importer, name, ispkg in iter_modules(path, prefix):
  File "/usr/lib/python2.6/", line 147, in iter_modules
    for name, ispkg in iter_importer_modules(i, prefix):
  File "/usr/lib/python2.6/", line 211, in iter_modules
    for fn in os.listdir(path):
OSError: [Errno 13] Permission denied: './bar'

Proposed patch:

Seems like an easy fix. In Python 3.1.2, change line 206 in /usr/lib/python3.1/ from

if not modname and os.path.isdir(path) and '.' not in fn:


if not modname and os.path.isdir(path) and '.' not in fn and os.access(path, os.R_OK):

Other versions much the same (although the specified line number will probably be different.)

Best regards,
Ben Okopnik
Date User Action Args
2011-04-24 03:34:54okopniksetrecipients: + okopnik
2011-04-24 03:34:53okopniksetmessageid: <>
2011-04-24 03:34:52okopniklinkissue11914 messages
2011-04-24 03:34:51okopnikcreate