Skip to content

Commit b8dc15b

Browse files
committed
Fix error in NEWS entry
1 parent fd7a311 commit b8dc15b

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

Lib/shutil.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,10 +526,13 @@ def _copytree(entries, src, dst, symlinks, ignore, copy_function,
526526
elif srcentry.is_dir():
527527
# Will raise shutil.Error containing multiple exceptions gathered
528528
# from recursion
529+
print(f"****copytree on {srcobj} {dstname}")
529530
copytree(srcobj, dstname, symlinks, ignore, copy_function,
530531
ignore_dangling_symlinks, dirs_exist_ok)
531532
else:
532533
# Can raise SpecialFileError or SameFileError
534+
print("*****************************")
535+
print(f"****copy_function on {srcobj} {dstname}")
533536
copy_function(srcobj, dstname)
534537
except SameFileError as err:
535538
errors.append((srcname, dstname, str(err)))

Lib/test/test_shutil.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ def custom_cpfun(a, b):
996996
@os_helper.skip_unless_symlink
997997
@unittest.skipIf(sys.platform == "vxworks",
998998
"fifo requires special path on VxWorks")
999-
def test_copytree_named_pipe(self):
999+
def test_copytree_directory_containing_named_pipe(self):
10001000
os.mkdir(TESTFN)
10011001
try:
10021002
subdir = os.path.join(TESTFN, "subdir")
@@ -1006,6 +1006,27 @@ def test_copytree_named_pipe(self):
10061006
os.mkfifo(pipe)
10071007
except PermissionError as e:
10081008
self.skipTest('os.mkfifo(): %s' % e)
1009+
try:
1010+
shutil.copytree(subdir, TESTFN2)
1011+
except shutil.Error as e:
1012+
errors = e.args[0]
1013+
self.assertEqual(len(errors), 1)
1014+
src, dst, error_msg = errors[0]
1015+
self.assertEqual("`%s` is a named pipe" % pipe, error_msg)
1016+
else:
1017+
self.fail("shutil.Error should have been raised")
1018+
finally:
1019+
shutil.rmtree(TESTFN, ignore_errors=True)
1020+
shutil.rmtree(TESTFN2, ignore_errors=True)
1021+
1022+
@unittest.skipUnless(hasattr(os, "mkfifo"), 'requires os.mkfifo()')
1023+
@os_helper.skip_unless_symlink
1024+
@unittest.skipIf(sys.platform == "vxworks",
1025+
"fifo requires special path on VxWorks")
1026+
def test_copytree_a_named_pipe(self):
1027+
os.mkdir(TESTFN)
1028+
try:
1029+
os.mkfifo(TESTFN2)
10091030
try:
10101031
shutil.copytree(TESTFN, TESTFN2)
10111032
except shutil.Error as e:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Make exception from :func:`shutil.copy_directory` readable when a
1+
Make exception from :func:`shutil.copytree` readable when a
22
:exc:`shutil.SameFileError` is raised.

0 commit comments

Comments
 (0)