[New-bugs-announce] [issue35367] FileExistsError During os.symlink() Displays Arrow in the Wrong Direction

Rich Jones report at bugs.python.org
Fri Nov 30 15:43:02 EST 2018


New submission from Rich Jones <miserlou at gmail.com>:

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

----------
components: Library (Lib)
messages: 330826
nosy: miserlou
priority: normal
severity: normal
status: open
title: FileExistsError During os.symlink() Displays Arrow in the Wrong Direction
type: behavior
versions: Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35367>
_______________________________________


More information about the New-bugs-announce mailing list