Message363537
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. |
|
Date |
User |
Action |
Args |
2020-03-06 20:00:35 | Matt Wozniski | set | recipients:
+ Matt Wozniski, thierry.parmentelat |
2020-03-06 20:00:35 | Matt Wozniski | set | messageid: <1583524835.18.0.230178099237.issue38894@roundup.psfhosted.org> |
2020-03-06 20:00:35 | Matt Wozniski | link | issue38894 messages |
2020-03-06 20:00:35 | Matt Wozniski | create | |
|