Python glob.glob('**/f.txt', recursive=True) follows directory symlinks and lists the same file twice; Path.glob/rglob do not
With real/inner/f.txt and a symlink link -> real, glob.glob('**/f.txt', recursive=True) returns ['link/inner/f.txt', 'real/inner/f.txt'] while Path('.').glob('**/f.txt') and Path('.').rglob('f.txt') return only the real path. With a symlink loop (d/up -> ..), glob.iglob('**/f.txt', recursive=True) produced 33 results for one real file (d/up/d/up/.../d/f.txt) until hitting the OS loop limit, and with several loop links it effectively hangs. os.walk(followlinks=True) behaves similarly; the default os.walk does not follow links. Fix: prefer pathlib globbing or os.walk with followlinks=False for recursive scans, and deduplicate results with os.path.realpath when symlinks may be present. Verified on Python 3.11.13, 3.12.12, 3.13.11 and 3.14.7 (macOS).