Message363850
`mylink.symlink_to(target)` and `mylink.link_to(target)` should both create a link (soft or hard) at *mylink* that points to *target*. But `link_to()` does the opposite - it creates *target* and points it towards *mylink*.
Correct behaviour from `symlink_to()`:
barney@acorn ~/projects/cpython $ touch /tmp/target
barney@acorn ~/projects/cpython $ ./python
Python 3.9.0a3+ (heads/bpo-39659-pathlib-getcwd-dirty:a4ba8a3, Feb 19 2020, 02:22:39)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pathlib
>>> p = pathlib.Path('/tmp/link')
>>> p.symlink_to('/tmp/target')
>>> exit()
barney@acorn ~/projects/cpython $ ls -l /tmp/link /tmp/target
lrwxrwxrwx 1 barney barney 11 Mar 10 21:20 /tmp/link -> /tmp/target
-rw-rw-r-- 1 barney barney 0 Mar 10 21:20 /tmp/target
Incorrect behaviour from `link_to()`:
barney@acorn ~/projects/cpython $ rm /tmp/link
barney@acorn ~/projects/cpython $ ./python
Python 3.9.0a3+ (heads/bpo-39659-pathlib-getcwd-dirty:a4ba8a3, Feb 19 2020, 02:22:39)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pathlib
>>> p = pathlib.Path('/tmp/link')
>>> p.link_to('/tmp/target')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/barney/projects/cpython/Lib/pathlib.py", line 1370, in link_to
self._accessor.link_to(self, target)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/link' -> '/tmp/target'
>>> # but...
>>> p = pathlib.Path('/tmp/target')
>>> p.link_to('/tmp/link')
>>> exit()
barney@acorn ~/projects/cpython $ ls -l /tmp/link /tmp/target
-rw-rw-r-- 2 barney barney 0 Mar 10 21:20 /tmp/link
-rw-rw-r-- 2 barney barney 0 Mar 10 21:20 /tmp/target |
|
Date |
User |
Action |
Args |
2020-03-10 21:31:06 | barneygale | set | recipients:
+ barneygale |
2020-03-10 21:31:06 | barneygale | set | messageid: <1583875866.01.0.524310586519.issue39925@roundup.psfhosted.org> |
2020-03-10 21:31:05 | barneygale | link | issue39925 messages |
2020-03-10 21:31:05 | barneygale | create | |
|