Commit eca15c1f authored by Ka-Ping Yee's avatar Ka-Ping Yee

Add inode checks to detect circular symbolic links (so that the

    Tools/idle/idlelib link doesn't cause an infinite loop -- aack!)
parent 59685c51
...@@ -1458,7 +1458,8 @@ class ModuleScanner(Scanner): ...@@ -1458,7 +1458,8 @@ class ModuleScanner(Scanner):
"""An interruptible scanner that searches module synopses.""" """An interruptible scanner that searches module synopses."""
def __init__(self): def __init__(self):
roots = map(lambda dir: (dir, ''), pathdirs()) 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)): def submodules(self, (dir, package)):
children = [] children = []
...@@ -1471,7 +1472,10 @@ class ModuleScanner(Scanner): ...@@ -1471,7 +1472,10 @@ class ModuleScanner(Scanner):
children.sort() # so that spam.py comes before spam.pyc or spam.pyo children.sort() # so that spam.py comes before spam.pyc or spam.pyo
return children return children
def ispackage(self, (dir, package)): 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) return ispackage(dir)
def run(self, callback, key=None, completer=None): def run(self, callback, key=None, completer=None):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment