New submission from Barney Gale <barney.g...@gmail.com>:

`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

----------
components: Library (Lib)
messages: 363850
nosy: barneygale
priority: normal
severity: normal
status: open
title: `pathlib.Path.link_to()` has the wrong argument order
type: behavior
versions: Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39925>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to