Skip to content

Commit ee9b825

Browse files
committed
Store list of device ids and inodes
This allows us to detect repeating paths in a more general way.
1 parent a82623e commit ee9b825

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

bpython/importcompletion.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ class ModuleGatherer:
4141
def __init__(self, path=None, skiplist=None):
4242
# The cached list of all known modules
4343
self.modules = set()
44-
# List of stored paths to compare against so that real paths are not repeated
45-
# handles symlinks not mount points
44+
# List of (st_dev, st_ino) to compare against so that paths are not repeated
4645
self.paths = set()
4746
# Patterns to skip
4847
self.skiplist = skiplist if skiplist is not None else tuple()
@@ -187,8 +186,9 @@ def find_modules(self, path):
187186
else:
188187
if is_package:
189188
path_real = Path(pathname).resolve()
190-
if path_real not in self.paths:
191-
self.paths.add(path_real)
189+
stat = path_real.stat()
190+
if (stat.st_dev, stat.st_ino) not in self.paths:
191+
self.paths.add((stat.st_dev, stat.st_ino))
192192
for subname in self.find_modules(path_real):
193193
if subname != "__init__":
194194
yield f"{name}.{subname}"

0 commit comments

Comments
 (0)