Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Documentation for pathlib.Path.symlink_to is incorrectly constrained #105900

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
jaraco opened this issue Jun 18, 2023 · 2 comments
Closed

Documentation for pathlib.Path.symlink_to is incorrectly constrained #105900

jaraco opened this issue Jun 18, 2023 · 2 comments
Labels
docs Documentation in the Doc dir topic-pathlib

Comments

@jaraco
Copy link
Member

jaraco commented Jun 18, 2023

Documentation

The docs for symlink_to state:

target_is_directory must be true (default False) if the link’s target is a directory.

That's not precisely correct. I experimented and symlink_to seems to follow the same behavior as os.symlink, which provides the correct (though more complicated) guidance:

If the target is present, the type of the symlink will be created to match. Otherwise, the symlink will be created as a directory if target_is_directory is True or a file symlink (the default) otherwise.

That is, both calls will infer the type of the target if it's present. The caller need not pass target_is_directory if the target is an extant directory. The symlink_to documentation is misleading and incorrect.

Linked PRs

@jaraco jaraco added the docs Documentation in the Doc dir label Jun 18, 2023
@jaraco
Copy link
Member Author

jaraco commented Jun 18, 2023

As a demo:

>>> import os, pathlib
>>> os.name
'nt'
>>> pathlib.Path('foo').mkdir()
>>> pathlib.Path('bar').symlink_to('foo')
>>> os.path.isdir('bar')
True

barneygale added a commit to barneygale/cpython that referenced this issue Jan 13, 2024
…)` docs

Clarify that *target_is_directory* only matters if the target doesn't
exist.
@barneygale barneygale added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Jan 13, 2024
barneygale added a commit that referenced this issue Jan 23, 2024
#114035)

Clarify that *target_is_directory* only matters if the target doesn't
exist.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jan 23, 2024
…)` docs (pythonGH-114035)

Clarify that *target_is_directory* only matters if the target doesn't
exist.
(cherry picked from commit b822b85)

Co-authored-by: Barney Gale <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jan 23, 2024
…)` docs (pythonGH-114035)

Clarify that *target_is_directory* only matters if the target doesn't
exist.
(cherry picked from commit b822b85)

Co-authored-by: Barney Gale <[email protected]>
barneygale added a commit that referenced this issue Jan 23, 2024
….)` docs (GH-114035) (#114464)

Clarify that *target_is_directory* only matters if the target doesn't
exist.
(cherry picked from commit b822b85)

Co-authored-by: Barney Gale <[email protected]>
barneygale added a commit that referenced this issue Jan 23, 2024
….)` docs (GH-114035) (#114465)

Clarify that *target_is_directory* only matters if the target doesn't
exist.
(cherry picked from commit b822b85)

Co-authored-by: Barney Gale <[email protected]>
@barneygale
Copy link
Contributor

Fixed!

aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
…)` docs (python#114035)

Clarify that *target_is_directory* only matters if the target doesn't
exist.
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
…)` docs (python#114035)

Clarify that *target_is_directory* only matters if the target doesn't
exist.
@picnixz picnixz removed needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir topic-pathlib
Projects
None yet
Development

No branches or pull requests

4 participants