[issue19887] Path.resolve() ENAMETOOLONG on pathologic symlinks

Serhiy Storchaka report at bugs.python.org
Thu Dec 5 14:05:41 CET 2013


Serhiy Storchaka added the comment:

Path.resolve() also fails when last link is absolute.

mkdir testdir
ln -s 0/0 testdir/1
ln -s 1/1 testdir/2
ln -s "$(readlink -f testdir)" testdir/0

Path('testdir/2').resolve() fails:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/serhiy/py/cpython/Lib/pathlib.py", line 1017, in resolve
    s = self._flavour.resolve(self)
  File "/home/serhiy/py/cpython/Lib/pathlib.py", line 273, in resolve
    raise RuntimeError("Symlink loop from %r" % cur)
RuntimeError: Symlink loop from '/home/serhiy/py/cpython/testdir/0'

Here is a patch which implements an algorithm similar to the algorithm used in posixpath.realpath().

----------
keywords: +patch
priority: low -> high
stage:  -> patch review
Added file: http://bugs.python.org/file32987/pathlib_resolve.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19887>
_______________________________________


More information about the Python-bugs-list mailing list