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

2013-12-07 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

How the test can be simpler? It is already simple.

You ca use pathlib_resolve_test.py but replace `os.symlink('.', 'testdir/0')` 
by `os.symlink(os.path.abspath('testdir'), 'testdir/0')`. Or use following 
shell commands:

mkdir testdir
for i in $(seq 100); do ln -s $((i-1))/$((i-1)) testdir/$i; done
ln -s $(pwd)/testdir testdir/0

./python -c import pathlib; print(pathlib.Path('testdir/100').resolve())

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19887
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-12-06 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I would prefer if you made the test simpler. The current setup makes it 
difficult to understand and reproduce with the command line.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19887
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-12-05 Thread Serhiy Storchaka

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 rep...@bugs.python.org
http://bugs.python.org/issue19887
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-12-05 Thread Vajrasky Kok

Vajrasky Kok added the comment:

Whoa, Serhiy, your patch won't fly on Windows Vista.

For starter, the patch does not use target_is_directory=True option in 
os.symlink. It needs that option when creating symlink to the directory on 
Windows Vista.

The maximum depth that pathlib can do on Windows Vista is 4 (Remember, this 
line: for depth in 0, 1, 2, 3, 10, 100?).

More than that:
OSError: [WinError 1921] The name of the file cannot be resolved by the system:
'C:\\Users\\vajrasky\\Code\\cpython\\@test_4220_tmp\\testdir\\link5'

Not sure whether the bug is in pathlib.py or _getfinalpathname (from nt module).

--
nosy: +vajrasky

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19887
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-12-05 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you Vajrasky. Here is a patch with fixed tests.

--
Added file: http://bugs.python.org/file32990/pathlib_resolve_2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19887
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-12-05 Thread Vajrasky Kok

Vajrasky Kok added the comment:

It works. Just a coding nitpick, instead of hardcoding os.symlink(src, dst, 
target_is_directory=True) in the test, you can use helper function in the test 
itself, self.dirlink.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19887
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-12-04 Thread Antoine Pitrou

Antoine Pitrou added the comment:

This is 
https://bitbucket.org/pitrou/pathlib/issue/9/pathresolve-fails-on-complex-symlinks

As noted there:

It's a ENAMETOOLONG error when calling readlink(), because there are many 
. components. This is really an edge case caused by the specific test setup, 
I don't think you'd have that many . components in real-world use.

--
priority: normal - low
title: Path.resolve() fails on deep symlinks - Path.resolve() ENAMETOOLONG on 
pathologic symlinks

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19887
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com