Bugs item #1438537, was opened at 2006-02-25 04:41
Message generated for change (Comment added) made by tjreedy
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 <keyword></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: Terry J. Reedy (tjreedy)
Date: 2006-03-05 22:18
Message:
Logged In: YES
user_id=593130
I am tempted to say that the restricted file permission is
the bug but enhancing pydoc seems reasonable to me. It
appears to open the file to get the first line of the doc
string. So I would have the exception clause instead
return a string like "Permission denied: you cannot import
this file. See your system administrator for more."
I would have attached such a mini patch here. Once a
committer reads this bug report and decides to make a
change, hardly any review is needed.
----------------------------------------------------------------------
Comment By: splitscreen (splitscreen)
Date: 2006-02-28 19:08
Message:
Logged In: YES
user_id=1126061
Patch #1440660 fixes this.
----------------------------------------------------------------------
Comment By: Grant Olson (logistix)
Date: 2006-02-28 16:55
Message:
Logged In: YES
user_id=699438
I personally don't have commit rights, but yes, it's
generally easiest if you post the patch to Patch manager and
put a cross reference note on the bug. Developers usually
give working patches precidence over bugs.
----------------------------------------------------------------------
Comment By: splitscreen (splitscreen)
Date: 2006-02-28 10:54
Message:
Logged In: YES
user_id=1126061
Yeah, I've modified it to tell the user which file caused
the problem.
Want the patch posting to the Patch Manager?
----------------------------------------------------------------------
Comment By: Grant Olson (logistix)
Date: 2006-02-26 18:32
Message:
Logged In: YES
user_id=699438
That patch sounds pretty-much right, but I think it should
print some feedback to stderr instead of silently swallowing
the exception.
----------------------------------------------------------------------
Comment By: splitscreen (splitscreen)
Date: 2006-02-25 07: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 04: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
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com