Skip to content

shutil.copytree makedirs exception #67826

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
yuriylevchenko mannequin opened this issue Mar 11, 2015 · 3 comments
Closed

shutil.copytree makedirs exception #67826

yuriylevchenko mannequin opened this issue Mar 11, 2015 · 3 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@yuriylevchenko
Copy link
Mannequin

yuriylevchenko mannequin commented Mar 11, 2015

BPO 23638
Nosy @vadmium
Superseder
  • bpo-20849: add exist_ok to shutil.copytree
  • 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 = <Date 2015-03-12.13:07:10.877>
    created_at = <Date 2015-03-11.10:41:47.229>
    labels = ['type-bug', 'library']
    title = 'shutil.copytree makedirs exception'
    updated_at = <Date 2015-03-12.13:07:10.849>
    user = 'https://bugs.python.org/yuriylevchenko'

    bugs.python.org fields:

    activity = <Date 2015-03-12.13:07:10.849>
    actor = 'r.david.murray'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-03-12.13:07:10.877>
    closer = 'r.david.murray'
    components = ['Library (Lib)']
    creation = <Date 2015-03-11.10:41:47.229>
    creator = 'yuriy_levchenko'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 23638
    keywords = []
    message_count = 3.0
    messages = ['237858', '237907', '237925']
    nosy_count = 2.0
    nosy_names = ['yuriy_levchenko', 'martin.panter']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '20849'
    type = 'behavior'
    url = 'https://bugs.python.org/issue23638'
    versions = ['Python 3.4']

    @yuriylevchenko
    Copy link
    Mannequin Author

    yuriylevchenko mannequin commented Mar 11, 2015

    We have a code:
    names = os.listdir(src)
    if ignore is not None:
    ignored_names = ignore(src, names)
    else:
    ignored_names = set()

        os.makedirs(dst)
            
        errors = []

    But if I had created this folder. I have exception.

    Maybe add "if"?

        if os.path.isdir(dst) is False:
            os.makedirs(dst)
            pass

    @yuriylevchenko yuriylevchenko mannequin added the stdlib Python modules in the Lib dir label Mar 11, 2015
    @vadmium
    Copy link
    Member

    vadmium commented Mar 11, 2015

    In case it’s not clear to others, the first bit of code is from the shutil.copytree() implementation at Lib/shutil.py:303.

    The documentation currently says “The destination directory . . . must not already exist”. Yuriy seems to be proposing to make copytree() use the existing destination directory, and only create it if it does not already exist. Perhaps you might be interested in bpo-20849, which proposes passing the os.makedirs(exist_ok=...) flag through, which would allow this functionality in a backwards-compatible way.

    @yuriylevchenko
    Copy link
    Mannequin Author

    yuriylevchenko mannequin commented Mar 12, 2015

    Thanks for the clarifications. Yes parameter will be a good solution!

    @yuriylevchenko yuriylevchenko mannequin added the type-bug An unexpected behavior, bug, or error label Mar 12, 2015
    @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
    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