Skip to content

Commit fd5babb

Browse files
author
Marc Herbert
committed
doc: recursive glob ** follows symlinks to directories
The existing note does already warn that "Using the ** pattern in large directory trees may consume an inordinate amount of time", however following symbolic links to directories brings that to entirely new levels; learned the hard way. I initially assumed this was a bug, tentatively fixed with a simple: - if not dironly or entry.is_dir(): + if not dironly or entry.is_dir(follow_symlinks=False): ... in glob.py#_iterdir(dirname, dironly): Later I found https://bugs.python.org/issue13968 in the git log and saw this is working as intended with even a symlink loop test.
1 parent d437012 commit fd5babb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Doc/library/glob.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ For example, ``'[?]'`` matches the character ``'?'``.
4949
single: **; in glob-style wildcards
5050
5151
If *recursive* is true, the pattern "``**``" will match any files and zero or
52-
more directories and subdirectories. If the pattern is followed by an
53-
``os.sep``, only directories and subdirectories match.
52+
more directories, subdirectories and symbolic links to directories. If the
53+
pattern is followed by an ``os.sep`` or ``os.altsep`` then files will not
54+
match.
5455

5556
.. note::
5657
Using the "``**``" pattern in large directory trees may consume

0 commit comments

Comments
 (0)