[New-bugs-announce] [issue7425] [PATCH] Improve the robustness of "pydoc -k" in the face of broken modules
Dave Malcolm
report at bugs.python.org
Wed Dec 2 21:49:32 CET 2009
New submission from Dave Malcolm <dmalcolm at redhat.com>:
I see occasional failures where a broken module prevents "pydoc -k" ("apropos") from working.
Examples of failures (from our downstream bug tracker) are:
https://bugzilla.redhat.com/show_bug.cgi?id=461419 : "pydoc -k" yields "NameError: name 'wglUseFontBitmapsW' is not
defined"
(a broken OpenGL/WGL/__init__.py module)
https://bugzilla.redhat.com/show_bug.cgi?id=447779 : "pydoc turbogears" doesn't work
(broken TurboGears module)
https://bugzilla.redhat.com/show_bug.cgi?id=246212 : "pydoc -k searchterm" MemoryError. permission denied.
(module only intended to be importable as "root" user)
In each case one or more of the many modules on the system are broken, and importing them leads to an exception being
raised that isn't ImportError.
In each case, the exception bubbles up through the pydoc call ands leads to it exiting.
Obviously the broken modules should be fixed, but it seems to me that pydoc could be more robust against this situation.
I'm attaching a simple patch which makes "pydoc -k" more robust against this situation, by silently discarding all
exceptions raised by imported modules.
How does this look?
One downstream bug report requested taking it further:
> Running "pydoc -k" should catch all exceptions while importing modules, and
> display failed modules _after_ all positive keyword matches (not in between).
> It also should redirect stdout/stderr while importing so error message e.a.
> don't clutter up the list of hits.
to deal with broken modules that spew error messages (this was in https://bugzilla.redhat.com/show_bug.cgi?id=461419#c3
); I've seen some do it to stdout and some to stderr.
How does this sound? I can try to update the patch for this too, if this sounds sane to you.
----------
components: Demos and Tools
files: make-pydoc-more-robust-001.patch
keywords: patch
messages: 95918
nosy: dmalcolm
severity: normal
status: open
title: [PATCH] Improve the robustness of "pydoc -k" in the face of broken modules
versions: Python 2.6
Added file: http://bugs.python.org/file15443/make-pydoc-more-robust-001.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7425>
_______________________________________
More information about the New-bugs-announce
mailing list