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.

classification
Title: FileExistsError During os.symlink() Displays Arrow in the Wrong Direction
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.8, Python 3.7, Python 3.6, Python 3.4, Python 3.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder: os.symlink: FileExistsError shows wrong message
View: 29657
Assigned To: Nosy List: miserlou
Priority: normal Keywords:

Created on 2018-11-30 20:43 by miserlou, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 11143 open Windson Yang, 2018-12-13 12:47
Messages (1)
msg330826 - (view) Author: Rich Jones (miserlou) Date: 2018-11-30 20:43
If I try to create a symlink which already exists, I get a FileExistsError. In this error message, the explanatory arrow is pointing in the wrong direction. This gave us a big scare in our logs!

Example:

```
$ ls
HELLO.txt
$ python3
Python 3.7.0 (default, Jul 23 2018, 20:22:55)
[Clang 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.symlink('HELLO.txt', 'GOODBYE.txt')
$ ls -lah *
lrwxr-xr-x  1 rjones  staff     9B Nov 30 15:36 GOODBYE.txt -> HELLO.txt
-rw-r--r--  1 rjones  staff     4B Nov 30 15:34 HELLO.txt
$ python3
Python 3.7.0 (default, Jul 23 2018, 20:22:55)
[Clang 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.symlink('HELLO.txt', 'GOODBYE.txt')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
FileExistsError: [Errno 17] File exists: 'HELLO.txt' -> 'GOODBYE.txt'
```

Notice that the arrow in the error message is pointing from HELLO to GOODBYE, but if you if you look at the `ls` output, it is pointing from GOODBYE to HELLO, which is the correct behavior.

The Python3 error message should be changed to reflect the correct direction of the symlink. 

This is a Python3 only bug, as the paths aren't displayed in Python2.

I can PR if this is accepted as a bug.

Thanks!
Rich
History
Date User Action Args
2022-04-11 14:59:08adminsetgithub: 79548
2018-12-13 12:47:21Windson Yangsetpull_requests: + pull_request10373
2018-11-30 20:56:11eryksunsetstatus: open -> closed
superseder: os.symlink: FileExistsError shows wrong message
resolution: duplicate
stage: resolved
2018-11-30 20:43:02miserloucreate