Issue21697
Created on 2014-06-09 13:19 by shajunxing, last changed 2015-07-25 11:58 by berker.peksag. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| 截图 - 2014年06月09日 - 21时14分13秒.png | shajunxing, 2014-06-09 13:19 | shutil.py source code screenshot | ||
| issue21697.diff | berker.peksag, 2014-06-13 11:22 | review | ||
| issue21697.diff | Eduardo.Seabra, 2014-06-16 20:46 | review | ||
| shutil_copytree_symlink_dir.patch | takluyver, 2015-07-10 21:44 | Patch including test | review | |
| Messages (9) | |||
|---|---|---|---|
| msg220088 - (view) | Author: Shajunxing (shajunxing) | Date: 2014-06-09 13:19 | |
While using shutil.copytree() and the source containing symbolic directory (not symbolic file), an error will be raised. I checked the source code and found an obvlous mistake: shutil.copytree() using os.path.islink() to checker whether the source is a symbolic link, it's okay, but after doing this, os.path.isdir() should be called because a symbolic link may either be a file or a directry, shutil.copytree() just treated all of them as file, and invoke copy_function to copy it, so error happens. I don't know whether newer versions have fixed this bug, but I googled it and found nothing. |
|||
| msg220112 - (view) | Author: Ned Deily (ned.deily) * | Date: 2014-06-09 19:32 | |
Thanks for the report. The bug is still present in the 3.4 and default (what will become the 3.5 release) branches; the 3.3 branch now only accepts security fixes. 2.7 does not fail. Would you be interested in producing a patch for the problem? |
|||
| msg220431 - (view) | Author: Berker Peksag (berker.peksag) * | Date: 2014-06-13 11:22 | |
Here's a patch. I'm getting the following error without modify Lib/shutil.py: ====================================================================== ERROR: test_copytree_symbolic_directory (test.test_shutil.TestShutil) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/berker/projects/cpython-default/Lib/test/test_shutil.py", line 650, in test_copytree_symbolic_directory shutil.copytree(src_dir, dst_dir) File "/home/berker/projects/cpython-default/Lib/shutil.py", line 342, in copytree raise Error(errors) shutil.Error: [('/tmp/tmpiy30_34s/src/link', '/tmp/tmpiy30_34s/dst/link', "[Errno 21] Is a directory: '/tmp/tmpiy30_34s/src/link'")] |
|||
| msg220758 - (view) | Author: Eduardo Seabra (Eduardo.Seabra) * | Date: 2014-06-16 20:46 | |
Berker Peksag, I don't think your patch is okay. When symlinks is set to true, it should copy the symbolic link of the directory. Your code is calling copytree instead. I think the following patch is working, no errors on regression tests. |
|||
| msg224546 - (view) | Author: Daniel Eriksson (puppet) * | Date: 2014-08-02 10:44 | |
I have tested both patches on CentOS 6.4 and Eduardo Seabra:s patch works correctly with symlinks=True |
|||
| msg232870 - (view) | Author: Björn Dahlgren (Björn.Dahlgren) | Date: 2014-12-18 11:12 | |
I ran across this bug too. Applying Eduardo's patch got my package working under Py 3.4 |
|||
| msg246587 - (view) | Author: Thomas Kluyver (takluyver) * | Date: 2015-07-10 21:44 | |
Here's my patch (I submitted the duplicate issue). I think it's functionally the same as Eduardo's, but it also adds a test. |
|||
| msg247347 - (view) | Author: Roundup Robot (python-dev) | Date: 2015-07-25 11:56 | |
New changeset e807f1d81cb6 by Berker Peksag in branch '3.4': Issue #21697: shutil.copytree() now correctly handles symbolic links that point to directories. https://hg.python.org/cpython/rev/e807f1d81cb6 New changeset 31f4041b9286 by Berker Peksag in branch '3.5': Issue #21697: shutil.copytree() now correctly handles symbolic links that point to directories. https://hg.python.org/cpython/rev/31f4041b9286 New changeset 8f65be73eb3a by Berker Peksag in branch 'default': Issue #21697: shutil.copytree() now correctly handles symbolic links that point to directories. https://hg.python.org/cpython/rev/8f65be73eb3a |
|||
| msg247348 - (view) | Author: Berker Peksag (berker.peksag) * | Date: 2015-07-25 11:58 | |
Thanks for the patches and testing! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2015-07-25 11:58:17 | berker.peksag | set | status: open -> closed resolution: fixed messages: + msg247348 stage: patch review -> resolved |
| 2015-07-25 11:56:18 | python-dev | set | nosy:
+ python-dev messages: + msg247347 |
| 2015-07-10 21:44:01 | takluyver | set | files:
+ shutil_copytree_symlink_dir.patch messages: + msg246587 |
| 2015-07-10 21:41:41 | berker.peksag | link | issue24609 superseder |
| 2015-07-10 21:41:32 | berker.peksag | set | assignee: berker.peksag nosy:
+ takluyver |
| 2014-12-18 11:12:33 | Björn.Dahlgren | set | nosy:
+ Björn.Dahlgren messages: + msg232870 |
| 2014-08-02 10:44:37 | puppet | set | nosy:
+ puppet messages: + msg224546 |
| 2014-06-16 20:46:07 | Eduardo.Seabra | set | files:
+ issue21697.diff nosy: + Eduardo.Seabra messages: + msg220758 |
| 2014-06-13 11:22:21 | berker.peksag | set | files:
+ issue21697.diff nosy:
+ berker.peksag keywords:
+ patch |
| 2014-06-09 19:32:29 | ned.deily | set | versions:
+ Python 3.4, Python 3.5, - Python 3.3 nosy: + ned.deily messages: + msg220112 keywords:
+ easy |
| 2014-06-09 13:19:19 | shajunxing | create | |