diff options
author | Ka-Ping Yee <ping@zesty.ca> | 2001-04-13 13:53:07 (GMT) |
---|---|---|
committer | Ka-Ping Yee <ping@zesty.ca> | 2001-04-13 13:53:07 (GMT) |
commit | eca15c1fb19c94d3a424156d072266c8d327663d (patch) | |
tree | cf4d2c1cfeb5074f43e156ea06e5d2458aa8d2cb /Lib/pydoc.py | |
parent | 59685c5193183eac7f8d852fd81bdc19e0f0ffc8 (diff) | |
download | cpython-eca15c1fb19c94d3a424156d072266c8d327663d.zip cpython-eca15c1fb19c94d3a424156d072266c8d327663d.tar.gz cpython-eca15c1fb19c94d3a424156d072266c8d327663d.tar.bz2 |
Add inode checks to detect circular symbolic links (so that the
Tools/idle/idlelib link doesn't cause an infinite loop -- aack!)
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-x | Lib/pydoc.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py index e5f7d80..5f37225 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -1458,7 +1458,8 @@ class ModuleScanner(Scanner): """An interruptible scanner that searches module synopses.""" def __init__(self): roots = map(lambda dir: (dir, ''), pathdirs()) - Scanner.__init__(self, roots, self.submodules, self.ispackage) + Scanner.__init__(self, roots, self.submodules, self.isnewpackage) + self.inodes = map(lambda (dir, pkg): os.stat(dir)[1], roots) def submodules(self, (dir, package)): children = [] @@ -1471,8 +1472,11 @@ class ModuleScanner(Scanner): children.sort() # so that spam.py comes before spam.pyc or spam.pyo return children - def ispackage(self, (dir, package)): - return ispackage(dir) + def isnewpackage(self, (dir, package)): + inode = os.stat(dir)[1] # detect circular symbolic links + if not (os.path.islink(dir) and inode in self.inodes): + self.inodes.append(inode) + return ispackage(dir) def run(self, callback, key=None, completer=None): if key: key = lower(key) |