6767class  Error (OSError ):
6868    pass 
6969
70+ class  ErrorGroup (Error ):
71+     """Used when gathering multiple exceptions""" 
72+ 
7073class  SameFileError (Error ):
7174    """Raised when source and destination are the same file.""" 
7275
@@ -531,10 +534,10 @@ def _copytree(entries, src, dst, symlinks, ignore, copy_function,
531534            else :
532535                # Can raise SpecialFileError or SameFileError 
533536                copy_function (srcobj , dstname )
534-         except  SameFileError  as  err :
535-             errors .append (( srcname ,  dstname ,  str ( err )) )
537+         except  ErrorGroup  as  err_group :
538+             errors .extend ( err_group . args [ 0 ] )
536539        except  Error  as  err :
537-             errors .extend ( err . args [ 0 ] )
540+             errors .append (( srcname ,  dstname ,  str ( err )) )
538541        except  OSError  as  why :
539542            errors .append ((srcname , dstname , str (why )))
540543    try :
@@ -544,7 +547,7 @@ def _copytree(entries, src, dst, symlinks, ignore, copy_function,
544547        if  getattr (why , 'winerror' , None ) is  None :
545548            errors .append ((src , dst , str (why )))
546549    if  errors :
547-         raise  Error (errors )
550+         raise  ErrorGroup (errors )
548551    return  dst 
549552
550553def  copytree (src , dst , symlinks = False , ignore = None , copy_function = copy2 ,
0 commit comments