[ python-Bugs-1438537 ] modules search in help() crashes on insufficient file perms

SourceForge.net noreply at sourceforge.net
Sat Feb 25 13:34:59 CET 2006


Bugs item #1438537, was opened at 2006-02-25 09:41
Message generated for change (Comment added) made by splitscreen
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1438537&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: A. Coder (hauptbeuteltier)
Assigned to: Nobody/Anonymous (nobody)
Summary: modules search in help() crashes on insufficient file perms

Initial Comment:
In the python interpreter, in the interactive online
help, typing <code>modules &lt;keyword&gt;</code>
throws a permission denied error (Errno 13) and dumps
the user back to the main interpreter if the user has
insufficient permission to read any .py file from the
site-packages directory.


Example:
~:$ ls -l /usr/lib/python2.4/site-packages/pygtk.py
-rw-r-----  1 root root 2619 2005-02-20 14:18
/usr/lib/python2.4/site-packages/pygtk.py
~:$ python
>>> help()

help> modules html

Here is a list of matching modules.  Enter any module
name to get more help.

HTMLParser - A parser for HTML and XHTML.
htmlentitydefs - HTML character entity references.
htmllib - HTML 2.0 parser.
markupbase - Shared support for scanning document type
declarations in HTML and XHTML.
pydoc - Generate Python documentation in HTML or text
for interactive use.
test.test_htmllib 
test.test_htmlparser - Tests for HTMLParser.py.
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.4/site.py", line 328, in __call__
    return pydoc.help(*args, **kwds)
  File "/usr/lib/python2.4/pydoc.py", line 1650, in
__call__
    self.interact()
  File "/usr/lib/python2.4/pydoc.py", line 1668, in
interact
    self.help(request)
  File "/usr/lib/python2.4/pydoc.py", line 1686, in help
    self.listmodules(split(request)[1])
  File "/usr/lib/python2.4/pydoc.py", line 1790, in
listmodules
    apropos(key)
  File "/usr/lib/python2.4/pydoc.py", line 1900, in apropos
    ModuleScanner().run(callback, key)
  File "/usr/lib/python2.4/pydoc.py", line 1886, in run
    desc = synopsis(path) or ''
  File "/usr/lib/python2.4/pydoc.py", line 182, in synopsis
    file = open(filename)
IOError: [Errno 13] Permission denied:
'/usr/lib/python2.4/site-packages/tageditor.py'
>>>

----------------------------------------------------------------------

Comment By: splitscreen (splitscreen)
Date: 2006-02-25 12:34

Message:
Logged In: YES 
user_id=1126061

Could this just be silently skipped? i.e returning None if
the user does not have the corrept permissions to access a
particular file?

Just wrap the 'file = open(filename)' in pydoc.py: line 182
in a try: except block returning None if there's an error
(such as permission denied).

I have written a patch I can supply if anyone wants it and
if this is the Right Thing To Do (TM).


----------------------------------------------------------------------

Comment By: A. Coder (hauptbeuteltier)
Date: 2006-02-25 09:44

Message:
Logged In: YES 
user_id=1420716

My apologies. The tageditor.py file had the same permissions
for my test as pygtk.py. The particular file is irrelevant
in this case, it only matters that a user has insufficient
permissions for any file in the site-packages directory.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1438537&group_id=5470


More information about the Python-bugs-list mailing list