Skip to content

Commit 14cdf29

Browse files
authored
Fix nonsense error messages in shutil.py
Attempting to copy a file onto a symlink to itself previously gave the error ``` shutil.Error: ['<', 'D', 'i', 'r', 'E', 'n', 't', 'r', 'y', ' ', "'", 's', 't', 'y', 'l', 'e', '.', 'c', 's', 's', "'", '>', ' ', 'a', 'n', 'd', ' ', "'", 'b', 'u', 'i', 'l', 'd', '/', 'h', 't', 'm', 'l', '/', 's', 't', 'y', 'l', 'e', '.', 'c', 's', 's', "'", ' ', 'a', 'r', 'e', ' ', 't', 'h', 'e', ' ', 's', 'a', 'm', 'e', ' ', 'f', 'i', 'l', 'e'] ```
1 parent 3adb23a commit 14cdf29

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

Lib/shutil.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,11 @@ def _copytree(entries, src, dst, symlinks, ignore, copy_function,
500500
# catch the Error from the recursive copytree so that we can
501501
# continue with other files
502502
except Error as err:
503-
errors.extend(err.args[0])
503+
if isinstance(err.args[0], list):
504+
# this is a recursive error
505+
errors.extend(err.args[0])
506+
else:
507+
errors.append((srcname, dstname, str(err)))
504508
except OSError as why:
505509
errors.append((srcname, dstname, str(why)))
506510
try:

0 commit comments

Comments
 (0)