Issue 35367: FileExistsError During os.symlink() Displays Arrow in the Wrong Direction (original) (raw)
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