Skip to content

Misleading error message when pathlib.Path.symlink_to() fails with permissions error #89389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dfntlymaybe mannequin opened this issue Sep 17, 2021 · 5 comments
Closed
Labels
3.8 (EOL) end of life stdlib Python modules in the Lib dir topic-pathlib type-bug An unexpected behavior, bug, or error

Comments

@dfntlymaybe
Copy link
Mannequin

dfntlymaybe mannequin commented Sep 17, 2021

BPO 45226
Nosy @barneygale, @dfntlymaybe

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2021-09-17.01:06:01.972>
labels = ['3.8', 'type-bug', 'library']
title = 'Misleading error message when pathlib.Path.symlink_to() fails with permissions error'
updated_at = <Date 2021-09-21.16:53:29.671>
user = 'https://github.com/dfntlymaybe'

bugs.python.org fields:

activity = <Date 2021-09-21.16:53:29.671>
actor = 'dfntlymaybe'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2021-09-17.01:06:01.972>
creator = 'dfntlymaybe'
dependencies = []
files = []
hgrepos = []
issue_num = 45226
keywords = []
message_count = 3.0
messages = ['401996', '402277', '402327']
nosy_count = 2.0
nosy_names = ['barneygale', 'dfntlymaybe']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue45226'
versions = ['Python 3.8']

@dfntlymaybe
Copy link
Mannequin Author

dfntlymaybe mannequin commented Sep 17, 2021

Reproduction Steps:
-------------------
Create a symlink in a directory without permissions:

>> from pathlib import Path
>>
>> target = Path('/tmp/tmp/target')
>> src = Path('/tmp/tmp/src')
>> src.symlink_to(target)

Actual:
-------
Permission error shows reversed order:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/rh/rh-python38/root/usr/lib64/python3.8/pathlib.py", line 1382, in symlink_to
    if self._closed:
  File "/opt/rh/rh-python38/root/usr/lib64/python3.8/pathlib.py", line 445, in symlink
    def symlink(a, b, target_is_directory):
PermissionError: [Errno 13] Permission denied: '/tmp/tmp/target' -> '/tmp/tmp/src'

Expected:
---------
Same as os.symlink the permission error should show the right symlink order:

>>> import os
>>>
>>> os.symlink(str(src), str(target))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
PermissionError: [Errno 13] Permission denied: '/tmp/tmp/src' -> '/tmp/tmp/target'

@dfntlymaybe dfntlymaybe mannequin added 3.8 (EOL) end of life type-bug An unexpected behavior, bug, or error stdlib Python modules in the Lib dir labels Sep 17, 2021
@barneygale
Copy link
Mannequin

barneygale mannequin commented Sep 20, 2021

os.symlink() and pathlib.Path.symlink_to() have reversed argument orders, but in the repro steps you're supplying arguments in the same order.

@dfntlymaybe
Copy link
Mannequin Author

dfntlymaybe mannequin commented Sep 21, 2021

Oh I see what you mean, sorry about that, maybe the comperison to os.symlink() was wrong.

It still feels wrong to me with since I am trying to make src symlink(point) to target and in the error message it looks like I am trying to do the other way around.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@barneygale
Copy link
Contributor

I believe this is a duplicate of #73843.

@barneygale
Copy link
Contributor

Closing - duplicate of #73843.

@barneygale barneygale closed this as not planned Won't fix, can't repro, duplicate, stale Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.8 (EOL) end of life stdlib Python modules in the Lib dir topic-pathlib type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants