mirror of
https://github.com/python/cpython.git
synced 2024-11-23 18:04:37 +08:00
Add inode checks to detect circular symbolic links (so that the
Tools/idle/idlelib link doesn't cause an infinite loop -- aack!)
This commit is contained in:
parent
59685c5193
commit
eca15c1fb1
10
Lib/pydoc.py
10
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)
|
||||
|
Loading…
Reference in New Issue
Block a user