Skip to content
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

os.chmod() does not follow symlinks on Windows #59616

Closed
atsuoishimoto mannequin opened this issue Jul 21, 2012 · 5 comments
Closed

os.chmod() does not follow symlinks on Windows #59616

atsuoishimoto mannequin opened this issue Jul 21, 2012 · 5 comments
Labels
OS-windows stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@atsuoishimoto
Copy link
Mannequin

atsuoishimoto mannequin commented Jul 21, 2012

BPO 15411
Nosy @atsuoishimoto, @tjguk, @asvetlov, @zware
Files
  • chmod_symlink_win32.patch
  • chmod_symlink_win32_2.patch
  • 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 2012-07-21.08:31:23.124>
    labels = ['type-feature', 'library', 'OS-windows']
    title = 'os.chmod() does not follow symlinks on Windows'
    updated_at = <Date 2019-04-26.19:53:54.688>
    user = 'https://github.com/atsuoishimoto'

    bugs.python.org fields:

    activity = <Date 2019-04-26.19:53:54.688>
    actor = 'BreamoreBoy'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)', 'Windows']
    creation = <Date 2012-07-21.08:31:23.124>
    creator = 'ishimoto'
    dependencies = []
    files = ['26462', '26464']
    hgrepos = []
    issue_num = 15411
    keywords = ['patch']
    message_count = 3.0
    messages = ['165996', '166003', '223300']
    nosy_count = 4.0
    nosy_names = ['ishimoto', 'tim.golden', 'asvetlov', 'zach.ware']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue15411'
    versions = ['Python 3.5']

    Linked PRs

    @atsuoishimoto
    Copy link
    Mannequin Author

    atsuoishimoto mannequin commented Jul 21, 2012

    os.chmod() should check symlinks if followsymlinks option is True on Windows.

    This is a cause of failure of test case

    test.test_shutil.TestShutil.test_copymode_follow_symlinks

    (bpo-13837)

    @atsuoishimoto atsuoishimoto mannequin added stdlib Python modules in the Lib dir OS-windows type-feature A feature request or enhancement labels Jul 21, 2012
    @atsuoishimoto
    Copy link
    Mannequin Author

    atsuoishimoto mannequin commented Jul 21, 2012

    Patch updated. Check symlinks only if supported by platform.

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jul 16, 2014

    Can we have a patch review on this please as it's holding up bpo-13837.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Dec 13, 2023
    serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Dec 13, 2023
    @serhiy-storchaka
    Copy link
    Member

    Unfortunately, the patch by @atsuoishimoto is too old and cannot be applied to the current code. The difference is so larger, that it is easier to write a new code from scratch than try to resolve conflicts iteratively.

    Which I did. My PR uses a different approach. Instead of resolving the symlink path, it opens a handle and changes file attributes by the handle (it is the recommended way). In future it may be possible to implement also os.fchmod().

    @serhiy-storchaka
    Copy link
    Member

    Now os.chmod() supports follow_symlinks=True on Windows. But by default it does not follow symlinks. Few versions later (in 3.15 or later) we can change the default. It will allow users to use os.lchmod() or os.chmod(follow_symlinks=False) if they need the old behavior, and it will work in several versions.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    OS-windows stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant