Skip to content

os.chmod() on Windows doesn't follow symlinks by default #11774

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
nineteendo opened this issue Apr 17, 2024 · 4 comments
Closed

os.chmod() on Windows doesn't follow symlinks by default #11774

nineteendo opened this issue Apr 17, 2024 · 4 comments

Comments

@nineteendo
Copy link
Contributor

nineteendo commented Apr 17, 2024

I just read python/cpython#113188 which states the following:

os.chmod() still does not follow symlinks by default on Windows

But the stubs say otherwise:

def chmod(path: FileDescriptorOrPath, mode: int, *, dir_fd: int | None = None, follow_symlinks: bool = True) -> None: ...

We should just use an ellipsis here:

def chmod(path: FileDescriptorOrPath, mode: int, *, dir_fd: int | None = None, follow_symlinks: bool = ...) -> None: ...
@srittau
Copy link
Collaborator

srittau commented Apr 17, 2024

Then the Python docs are wrong and should be fixed first: https://docs.python.org/3/library/os.html#os.chmod.

os.chmod(path, mode, *, dir_fd=None, follow_symlinks=True)

@nineteendo
Copy link
Contributor Author

It has already been fixed on the main branch: https://docs.python.org/3.13/library/os.html#os.chmod

The default value of follow_symlinks is False on Windows.

@srittau
Copy link
Collaborator

srittau commented Apr 17, 2024

Semi-fixed. It still says True in the signature, only when reading the low-contrast box on the next screen page, it states the correct default. Also, in older docs versions, it doesn't state that follow_symlinks doesn't exist/isn't supported on Windows.

@nineteendo
Copy link
Contributor Author

Also, in older docs versions, it doesn't state that follow_symlinks doesn't exist/isn't supported on Windows.

No, but os.supports_follow_symlinks exists for that purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants