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

shutil.move creates a new directory even on failure #86948

Closed
winsonluk mannequin opened this issue Dec 29, 2020 · 6 comments
Closed

shutil.move creates a new directory even on failure #86948

winsonluk mannequin opened this issue Dec 29, 2020 · 6 comments
Assignees
Labels
3.8 only security fixes 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@winsonluk
Copy link
Mannequin

winsonluk mannequin commented Dec 29, 2020

BPO 42782
Nosy @orsenthil, @JelleZijlstra, @miss-islington, @winsonluk
PRs
  • bpo-42782: Fail fast for permission errors in shutil.move() #24001
  • [3.8] bpo-42782: Fail fast for permission errors in shutil.move() (GH-24001) #24709
  • [3.9] bpo-42782: Fail fast for permission errors in shutil.move() (GH-24001) #24710
  • [3.8] bpo-42782: Fail fast for permission errors in shutil.move() (GH-24001) #24711
  • [3.8] bpo-42782: Fail fast for permission errors in shutil.move() (GH-24001) #24724
  • [3.9] bpo-42782: Fail fast for permission errors in shutil.move() (GH24001) #24725
  • [3.9] bpo-42782: fix broken shutil test #31971
  • 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 = 'https://github.com/orsenthil'
    closed_at = <Date 2021-03-03.16:04:24.296>
    created_at = <Date 2020-12-29.18:38:15.949>
    labels = ['3.8', 'type-bug', 'library', '3.9', '3.10']
    title = 'shutil.move creates a new directory even on failure'
    updated_at = <Date 2022-03-18.02:46:04.643>
    user = 'https://github.com/winsonluk'

    bugs.python.org fields:

    activity = <Date 2022-03-18.02:46:04.643>
    actor = 'orsenthil'
    assignee = 'orsenthil'
    closed = True
    closed_date = <Date 2021-03-03.16:04:24.296>
    closer = 'orsenthil'
    components = ['Library (Lib)']
    creation = <Date 2020-12-29.18:38:15.949>
    creator = 'winsonluk'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 42782
    keywords = ['patch']
    message_count = 6.0
    messages = ['384021', '384023', '387969', '388024', '388026', '415466']
    nosy_count = 4.0
    nosy_names = ['orsenthil', 'JelleZijlstra', 'miss-islington', 'winsonluk']
    pr_nums = ['24001', '24709', '24710', '24711', '24724', '24725', '31971']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'patch review'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue42782'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    @winsonluk winsonluk mannequin added 3.7 (EOL) end of life 3.10 only security fixes 3.8 only security fixes 3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Dec 29, 2020
    @winsonluk
    Copy link
    Mannequin Author

    winsonluk mannequin commented Dec 29, 2020

    shutil.move calls shutil.copytree(), then os.rmtree() (in that order). If the user does not have permission to delete the source directory, copytree succeeds but rmtree fails. The user sees an error (Permission Denied), but the destination directory is still created. The expected behavior should be a Permission Denied without the creation of the destination directory.

    @winsonluk
    Copy link
    Mannequin Author

    winsonluk mannequin commented Dec 29, 2020

    To replicate:

    $ mkdir foo
    $ sudo chown root foo
    $ sudo touch foo/child
    $ python3
    >>> import shutil
    >>> shutil.move('foo', 'bar')
    PermissionError
    $ ls foo
    child
    $ ls bar
    child

    If shutil.move() encountered a permission error and failed, bar should not have been created.

    @orsenthil orsenthil removed 3.7 (EOL) end of life labels Mar 2, 2021
    @orsenthil
    Copy link
    Member

    New changeset 132131b by Winson Luk in branch 'master':
    bpo-42782: Fail fast for permission errors in shutil.move() (GH-24001)
    132131b

    @miss-islington
    Copy link
    Contributor

    New changeset 59e8576 by Miss Islington (bot) in branch '3.8':
    bpo-42782: Fail fast for permission errors in shutil.move() (GH-24001)
    59e8576

    @orsenthil
    Copy link
    Member

    New changeset bf56684 by Senthil Kumaran in branch '3.9':
    [3.9] bpo-42782: Fail fast for permission errors in shutil.move() (GH-24001) (bpo-24725)
    bf56684

    @orsenthil
    Copy link
    Member

    New changeset e808c9d by Jelle Zijlstra in branch '3.9':
    [3.9] bpo-42782: fix broken shutil test (GH-31971)
    e808c9d

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes 3.9 only security fixes 3.10 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

    2 participants