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

Incorrect shutil.copytree() behaviour with symlinks #91205

Open
vajdaz mannequin opened this issue Mar 17, 2022 · 3 comments
Open

Incorrect shutil.copytree() behaviour with symlinks #91205

vajdaz mannequin opened this issue Mar 17, 2022 · 3 comments
Labels
3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@vajdaz
Copy link
Mannequin

vajdaz mannequin commented Mar 17, 2022

BPO 47049
Nosy @vajdaz
PRs
  • bpo-47049: Fix incorrect shutil.copytree() behaviour with symlinks #31967
  • 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 2022-03-17.18:50:19.316>
    labels = ['type-bug', 'library', '3.11']
    title = 'Incorrect shutil.copytree() behaviour with symlinks'
    updated_at = <Date 2022-04-04.22:13:23.663>
    user = 'https://github.com/vajdaz'

    bugs.python.org fields:

    activity = <Date 2022-04-04.22:13:23.663>
    actor = 'vajdaz'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2022-03-17.18:50:19.316>
    creator = 'vajdaz'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 47049
    keywords = ['patch']
    message_count = 2.0
    messages = ['415437', '416700']
    nosy_count = 1.0
    nosy_names = ['vajdaz']
    pr_nums = ['31967']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue47049'
    versions = ['Python 3.11']

    @vajdaz
    Copy link
    Mannequin Author

    vajdaz mannequin commented Mar 17, 2022

    shutil.copytree incorrectly does not copy symlink contents if called
    with symlink=False and ignore_dangling_symlinks=True.

    The wrong behaviour can be reproduced like this:

    $ tree
    .
    └── a
        ├── a.txt
        └── b
            └── a.txt -> ../a.txt
    
    $ python3 -c "import shutil;shutil.copytree('a/b', 'c', symlinks=False, ignore_dangling_symlinks=True)"

    As a result directoy c will be created but it will remain empty.
    Expected result is a file c/a.txt with the contents of a/b/a.txt.

    @vajdaz vajdaz mannequin added 3.11 only security fixes stdlib Python modules in the Lib dir labels Mar 17, 2022
    @vajdaz
    Copy link
    Mannequin Author

    vajdaz mannequin commented Apr 4, 2022

    Because I am a first contributor, the automatic quality checks on GitHub have to be manually started by somebody. How can I reqest this and by whom?

    @vajdaz vajdaz mannequin added type-bug An unexpected behavior, bug, or error labels Apr 4, 2022
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @eakr9014
    Copy link

    This still seems to be an issue even though the underlying PR was closed. Even though ignore_dangling_symlinks is passed to recursive calls of copy_tree now, the function will still incorrectly classify symlinks as dangling even if they aren't because it attempts to do a os.readlink relative to the current working directory, not the copied directory

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant