Matt Wozniski <[email protected]> added the comment:
A simple test case for this issue:
~>mkdir tmp
~>cd tmp
tmp>touch 1.txt
tmp>ln -s subdir/file 2.txt
tmp>touch 3.txt
tmp>ls -l
total 0
-rw-rw-r-- 1 mwoznisk general 0 Mar 6 14:52 1.txt
lrwxrwxrwx 1 mwoznisk general 11 Mar 6 14:52 2.txt -> subdir/file
-rw-rw-r-- 1 mwoznisk general 0 Mar 6 14:52 3.txt
tmp>python3.8 -c "import pathlib; print(list(pathlib.Path('.').glob('*')))"
[PosixPath('1.txt'), PosixPath('2.txt'), PosixPath('3.txt')]
tmp>mkdir subdir
tmp>python3.8 -c "import pathlib; print(list(pathlib.Path('.').glob('*')))"
[PosixPath('1.txt'), PosixPath('2.txt'), PosixPath('3.txt'),
PosixPath('subdir')]
So far so good, but if the subdirectory isn't readable, things fall apart:
tmp>chmod 000 subdir
tmp>python3.8 -c "import pathlib; print(list(pathlib.Path('.').glob('*')))"
[PosixPath('1.txt')]
Looks like this is caused by entry.is_dir() in pathlib._WildcardSelector
raising a PermissionError when trying to check if a symlink pointing into an
unreadable directory is or isn't a directory. EACCESS isn't in IGNORED_ERROS
(sic) and so the loop over directory entries is broken out of, and the "except
PermissionError:" block in _select_from swallows the exception so that the
failure is silent.
----------
nosy: +Matt Wozniski
versions: +Python 3.8 -Python 3.7
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue38894>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com