- Python Home
- About
- News
- Documentation
- Downloads
- Community
- Foundation
- Developer's Guide
- Issue Tracker
- Issues
- Summaries
- User
- Administration
- Help
Issue39925
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2020-03-10 21:31 by barneygale, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 18909 | open | barneygale, 2020-03-11 00:02 | |
| Messages (5) | |||
|---|---|---|---|
| msg363850 - (view) | Author: Barney Gale (barneygale) * | Date: 2020-03-10 21:31 | |
`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 |
|||
| msg363856 - (view) | Author: Eric V. Smith (eric.smith) * ![]() |
Date: 2020-03-10 21:48 | |
I think it's too late to change this. Is this a documentation issue? |
|||
| msg363857 - (view) | Author: Barney Gale (barneygale) * | Date: 2020-03-10 21:53 | |
I'm not sure how it can be fixed on the documentation side - it's difficult to explain that `a.link_to(b)` creates a link from B to A, and not vice-versa. We could introduce a new method that does the right thing? `Path.hardlink_to()`? |
|||
| msg363883 - (view) | Author: Karthikeyan Singaravelan (xtreak) * ![]() |
Date: 2020-03-11 06:06 | |
This seems to be a duplicate of issue39291. |
|||
| msg363887 - (view) | Author: Eric V. Smith (eric.smith) * ![]() |
Date: 2020-03-11 08:48 | |
Agreed it's a duplicate, so I'm closing this. For any further discussion, please use issue39291, or better yet, do as it suggests and discuss this on python-dev. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:27 | admin | set | github: 84106 |
| 2020-03-11 08:48:30 | eric.smith | set | status: open -> closed superseder: "pathlib.Path.link_to()" and "pathlib.Path.symlink_to()" have reversed usage messages: + msg363887 resolution: duplicate stage: patch review -> resolved |
| 2020-03-11 06:06:08 | xtreak | set | nosy:
+ xtreak, pitrou messages: + msg363883 |
| 2020-03-11 00:02:30 | barneygale | set | keywords:
+ patch stage: patch review pull_requests: + pull_request18264 |
| 2020-03-10 21:53:30 | barneygale | set | messages: + msg363857 |
| 2020-03-10 21:48:34 | eric.smith | set | nosy:
+ eric.smith messages: + msg363856 |
| 2020-03-10 21:31:05 | barneygale | create | |


