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

Cannot copy the same directory structure to the same destination more than once #66330

Closed
CsabaMakara mannequin opened this issue Aug 4, 2014 · 4 comments
Closed

Cannot copy the same directory structure to the same destination more than once #66330

CsabaMakara mannequin opened this issue Aug 4, 2014 · 4 comments
Labels
stdlib Python modules in the Lib dir type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@CsabaMakara
Copy link
Mannequin

CsabaMakara mannequin commented Aug 4, 2014

BPO 22132
Nosy @merwok, @dstufft
Files
  • example.py: Example script of the problem
  • 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 2014-08-07.13:05:41.952>
    created_at = <Date 2014-08-04.07:15:34.810>
    labels = ['library', 'type-crash']
    title = 'Cannot copy the same directory structure to the same destination more than once'
    updated_at = <Date 2014-08-07.13:05:41.950>
    user = 'https://bugs.python.org/CsabaMakara'

    bugs.python.org fields:

    activity = <Date 2014-08-07.13:05:41.950>
    actor = 'eric.araujo'
    assignee = 'none'
    closed = True
    closed_date = <Date 2014-08-07.13:05:41.952>
    closer = 'eric.araujo'
    components = ['Distutils']
    creation = <Date 2014-08-04.07:15:34.810>
    creator = 'Csaba.Makara'
    dependencies = []
    files = ['36244']
    hgrepos = []
    issue_num = 22132
    keywords = []
    message_count = 4.0
    messages = ['224691', '224749', '224995', '225010']
    nosy_count = 3.0
    nosy_names = ['eric.araujo', 'dstufft', 'Csaba.Makara']
    pr_nums = []
    priority = 'normal'
    resolution = 'wont fix'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue22132'
    versions = ['Python 3.4']

    @CsabaMakara
    Copy link
    Mannequin Author

    CsabaMakara mannequin commented Aug 4, 2014

    If I use the distutils.dir_util.copy_tree to copy the same directory structure multiple times to the same place (even from multiple sources) but I remove and recreate the target_directory before each copy, the following exception accurs:

    g:\_Programming>py example.py
    Traceback (most recent call last):
      File "E:\Python34\lib\distutils\file_util.py", line 41, in _copy_file_contents
        fdst = open(dst, 'wb')
    FileNotFoundError: [Errno 2] No such file or directory: 'c:\\bin\\folder_inside\
    \file_inside.txt'
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "example.py", line 13, in <module>
        dir_util.copy_tree(source_folder2, target_folder)
      File "E:\Python34\lib\distutils\dir_util.py", line 160, in copy_tree
        verbose=verbose, dry_run=dry_run))
      File "E:\Python34\lib\distutils\dir_util.py", line 164, in copy_tree
        dry_run=dry_run)
      File "E:\Python34\lib\distutils\file_util.py", line 143, in copy_file
        _copy_file_contents(src, dst)
      File "E:\Python34\lib\distutils\file_util.py", line 44, in _copy_file_contents
    "could not create '%s': %s" % (dst, e.strerror))
    

    distutils.errors.DistutilsFileError: could not create 'c:\bin\folder_inside\file
    _inside.txt': No such file or directory


    If the target_folder is not deleted, the problem won't appear.
    The problem seems to be the handling of the inner directories. In the second attempt the inner folders are thought to be existing, but they are not.

    See the attached script.

    @CsabaMakara CsabaMakara mannequin added stdlib Python modules in the Lib dir type-crash A hard crash of the interpreter, possibly with a core dump labels Aug 4, 2014
    @merwok
    Copy link
    Member

    merwok commented Aug 4, 2014

    Thanks for the report. Did you find this issue with a setup.py file or with direct usage of dir_utils.copy_tree? These distutils modules are not meant for general use, so bugs that don’t occur during regular use of setup.py files will probably not get fixed. (Distutils has fragile internals so it’s policy to do as little change as possible to avoid breaking other things.)

    @CsabaMakara
    Copy link
    Mannequin Author

    CsabaMakara mannequin commented Aug 7, 2014

    Sorry for the late answer.
    It was a direct usage of the dir_utils.copy_tree.
    I absolutely understand you don't want to touch it.

    @merwok
    Copy link
    Member

    merwok commented Aug 7, 2014

    Thanks. There is a function intended for general use: shutil.copytree; it may have the same behavior (not a bug if it's documented).

    @merwok merwok closed this as completed Aug 7, 2014
    @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-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant