Bug 649707

Summary: "pydoc -k" searches fail when run as non-root and it cannot access some file
Product: [Fedora] Fedora Reporter: Matěj Cepl <mcepl>
Component: pythonAssignee: Dave Malcolm <dmalcolm>
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 14CC: dcantrell, dmalcolm, hdegoede, ivazqueznet, james.antill, jonathansteffan, mcepl
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard: abrt_hash:6d4b909e
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 526402 Environment:
Last Closed: 2010-11-04 15:07:14 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 526402    
Bug Blocks:    

Description Matěj Cepl 2010-11-04 11:20:42 UTC
+++ This bug was initially created as a clone of Bug #526402 +++


abrt detected a crash.


How to reproduce
-----
1.
2.
3.


Comment
-----
I don't know why pydoc on the command line needs gopher. Seems bizzare.

Additional information
======


Attached files
----
backtrace

cmdline
-----
/usr/bin/python2.6 /usr/bin/pydoc -k hmac 


component
-----
python


executable
-----
/usr/bin/pydoc


kernel
-----
2.6.31.1-48.fc12.x86_64


package
-----
python-2.6.2-2.fc12


uuid
-----
6d4b909e

--- Additional comment from mcepl on 2009-09-30 01:44:06 EDT ---

Created attachment 363123 [details]
File: backtrace

--- Additional comment from dmalcolm on 2009-10-12 19:11:48 EDT ---

"pydoc -k" is searching through all modules on your system.

It's failing on "/home/matej/.python-lib/mechanize/_useragent.py", which looks like a locally-installed version of the mechanize package.  What version of mechanize is that?

--- Additional comment from mcepl on 2009-10-13 03:34:10 EDT ---

Yes, that's it. Sorry for the noise.

--- Additional comment from mcepl on 2009-10-13 03:36:40 EDT ---

Well, that was hasty:

bradford:~$ pydoc -k hmac
hmac - HMAC (Keyed-Hashing for Message Authentication) Python module.
Crypto.Hash.HMAC - HMAC (Keyed-Hashing for Message Authentication) Python module.

(process:6115): Gdk-CRITICAL **: gdk_keymap_get_for_display: assertion `GDK_IS_DISPLAY (display)' failed

(process:6115): Gdk-CRITICAL **: gdk_screen_get_root_window: assertion `GDK_IS_SCREEN (screen)' failed

** (process:6115): CRITICAL **: egg_keymap_resolve_virtual_modifiers: assertion `GDK_IS_KEYMAP (keymap)' failed

** (process:6115): CRITICAL **: egg_keymap_resolve_virtual_modifiers: assertion `GDK_IS_KEYMAP (keymap)' failed

** (process:6115): CRITICAL **: egg_keymap_resolve_virtual_modifiers: assertion `GDK_IS_KEYMAP (keymap)' failed
Traceback (most recent call last):
  File "/usr/bin/pydoc", line 5, in <module>
    pydoc.cli()
  File "/usr/lib64/python2.6/pydoc.py", line 2264, in cli
    apropos(val)
  File "/usr/lib64/python2.6/pydoc.py", line 1962, in apropos
    ModuleScanner().run(callback, key)
  File "/usr/lib64/python2.6/pydoc.py", line 1927, in run
    for importer, modname, ispkg in pkgutil.walk_packages(onerror=onerror):
  File "/usr/lib64/python2.6/pkgutil.py", line 110, in walk_packages
    __import__(name)
  File "/usr/lib64/python2.6/site-packages/parted/__init__.py", line 28, in <module>
    from _ped import AlignmentException
RuntimeError: pyparted requires root access
bradford:~$ 

Even when I have no local python library, pydoc fails .... Why in the world it needs parted???

--- Additional comment from dmalcolm on 2009-10-13 11:56:06 EDT ---

Well, it's iterating through all installed packages, importing them.  One of the installed packages is "parted", and parted appears to have a hard requirement on being _imported_ as root.

Looks to me like the parted code should be importable as non-root, but only runnable by root.  Alternatively, perhaps "pydoc -k" could be made to handle this kind of case.

Renaming and reasssiging to "parted".  If it's not feasible to fix there, reassign back to python and I can look at a better onerror handler.

========

Actually I think this comment lead the original bug on the dead way. The issue is not how are particular modules imported, but that pydoc is completely unable to deal with files to which doesn't have an access to. It will always happen that some file for one reason of other is not accessible to mere user, so pydoc -k should be able to deal with such circumstance. Also exceptions should be properly handled and not just thrown out to hopeless user. Especially in case of the program which is targeted towards inexperienced users as well.

See my current reproduction of the same problem:

jakoubek:~ $ LANG=en_US pydoc -k hmac
hmac - HMAC (Keyed-Hashing for Message Authentication) Python module.
Crypto.Hash.HMAC - HMAC (Keyed-Hashing for Message Authentication) Python module.
Crypto.SelfTest.Hash.test_HMAC - Self-test suite for Crypto.Hash.HMAC
** Message: pygobject_register_sinkfunc is deprecated (ClutterActor)
** Message: pygobject_register_sinkfunc is deprecated (ClutterAlpha)
** Message: pygobject_register_sinkfunc is deprecated (ClutterPath)
** Message: pygobject_register_sinkfunc is deprecated (ClutterInterval)
** Message: pygobject_register_sinkfunc is deprecated (GstObject)
gdata.Crypto.Hash.HMAC - HMAC (Keyed-Hashing for Message Authentication) Python module.
gdata.tlslite.utils.hmac - HMAC (Keyed-Hashing for Message Authentication) Python module.
2010-11-04 12:15:09.492289: ERROR: Could not load the stocks from /home/matej/.gnome2/invest-applet/stocks.pickle: [Errno 2] No such file or directory: '/home/matej/.gnome2/invest-applet/stocks.pickle'
You must run this application as root
jakoubek:~ $

Comment 1 Dave Malcolm 2010-11-04 15:07:14 UTC

*** This bug has been marked as a duplicate of bug 461419 ***