summaryrefslogtreecommitdiff
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2009-06-23 20:37:26 +0000
committerR. David Murray <rdmurray@bitdance.com>2009-06-23 20:37:26 +0000
commitc4c84e1a1954a1f46e160d2bc53927347d9e3159 (patch)
tree56d42796360d384bd679772f051cb97191320df5 /Lib/pydoc.py
parent5f1446ac5b9d117ed77e4b12e99a007d276483a5 (diff)
downloadcpython-git-c4c84e1a1954a1f46e160d2bc53927347d9e3159.tar.gz
Merged revisions 73529 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r73529 | r.david.murray | 2009-06-23 14:02:46 -0400 (Tue, 23 Jun 2009) | 4 lines Fix issue 5230 by having pydoc's safeimport check to see if the import error was thrown from itself in order to decide if the module can't be found. Thanks to Lucas Prado Melo for collaborating on the fix and tests. ........
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-xLib/pydoc.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 1103b013cc..9920fcb2de 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -55,6 +55,7 @@ Richard Chamberlain, for the first implementation of textdoc.
import sys, imp, os, re, types, inspect, __builtin__, pkgutil
from repr import Repr
from string import expandtabs, find, join, lower, split, strip, rfind, rstrip
+from traceback import extract_tb
try:
from collections import deque
except ImportError:
@@ -299,9 +300,9 @@ def safeimport(path, forceload=0, cache={}):
elif exc is SyntaxError:
# A SyntaxError occurred before we could execute the module.
raise ErrorDuringImport(value.filename, info)
- elif exc is ImportError and \
- split(lower(str(value)))[:2] == ['no', 'module']:
- # The module was not found.
+ elif exc is ImportError and extract_tb(tb)[-1][2]=='safeimport':
+ # The import error occurred directly in this function,
+ # which means there is no such module in the path.
return None
else:
# Some other error occurred during the importing process.