[issue36035] pathlib.Path().rglob() breaks with broken symlinks

2019-02-22 Thread Jörg Stucke

Jörg Stucke  added the comment:

As expected the Windows CI build failed.
All test fails were caused by:
OSError: [WinError 1921] The name of the file cannot be resolved by the system: 
'C:\\projects\\cpython\\build\\test_python_936\\@test_936_tmp\\brokenLinkLoop'

Therefore, I added WinError 1921 to _IGNORED_WINERRORS as suggested by Eryk Sun.

--

___
Python tracker 
<https://bugs.python.org/issue36035>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36035] pathlib.Path().rglob() breaks with broken symlinks

2019-02-22 Thread Jörg Stucke

Jörg Stucke  added the comment:

I tried to add a test file in https://github.com/python/cpython/pull/11988 
To fix all now broken tests I had to add a try except block to the 
_WildcardSelector as well (analogous to the _RecursiveWildcardSelector).

I could only check on Linux and I have no idea how it behaves on any other OS.

--

___
Python tracker 
<https://bugs.python.org/issue36035>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36035] pathlib.Path().rglob() breaks with broken symlinks

2019-02-22 Thread Jörg Stucke

Change by Jörg Stucke :


--
pull_requests: +12011

___
Python tracker 
<https://bugs.python.org/issue36035>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36035] pathlib.Path().rglob() breaks with broken symlinks

2019-02-19 Thread Jörg Stucke

Jörg Stucke  added the comment:

A possible solution for python 3.7+ could be to add "ELOOP" to _IGNORED_ERROS 
in pathlib but I'm not exactly sure of the side effects.

--

___
Python tracker 
<https://bugs.python.org/issue36035>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36035] pathlib.Path().rglob() breaks with broken symlinks

2019-02-19 Thread Jörg Stucke

New submission from Jörg Stucke :

When using rglob() to iterate over the files of a directory containing a broken 
symlink (a link pointing to itself) rglob breaks with "[Errno 40] Too many 
levels of symbolic links" (OS: Linux).

Steps to reproduce:

mkdir tmp
touch foo
ls -s foo tmp/foo
cd tmp
file foo
foo: broken symbolic link to foo

python3
>>> from pathlib import Path
>>> for f in Path().rglob("*"):
print(x)

foo
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python3.8/pathlib.py", line 1105, in rglob
for p in selector.select_from(self):
  File "/usr/local/lib/python3.8/pathlib.py", line 552, in _select_from
for starting_point in self._iterate_directories(parent_path, is_dir, 
scandir):
  File "/usr/local/lib/python3.8/pathlib.py", line 536, in _iterate_directories
entry_is_dir = entry.is_dir()
OSError: [Errno 40] Too many levels of symbolic links: './foo'


What is more, stat(), is_dir(), is_file() and exists() also do not like those 
broken links:
>>> Path("foo").is_file()
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python3.8/pathlib.py", line 1361, in is_file
return S_ISREG(self.stat().st_mode)
  File "/usr/local/lib/python3.8/pathlib.py", line 1151, in stat
return self._accessor.stat(self)
OSError: [Errno 40] Too many levels of symbolic links: 'foo'


Is this intended behaviour or is this a bug? I guess it's not intended, since 
it makes it impossible to iterate over such a directory with rglob(). I could 
not find anything similar in the bug tracker, but 
https://bugs.python.org/issue26012 seems to be related.

Tested with Python 3.8.0a1, 3.6.7 and 3.5.2 (OS: Linux Mint 19)

--
components: Library (Lib)
messages: 335937
nosy: Jörg Stucke
priority: normal
severity: normal
status: open
title: pathlib.Path().rglob() breaks with broken symlinks
type: behavior
versions: Python 3.5, Python 3.6, Python 3.8

___
Python tracker 
<https://bugs.python.org/issue36035>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com