Browse code

encode filenames to system encoding before calling shutils.copy2()

shutils.copy2() eventually calls os.stat(), which fails if given a
unicode object. So, encode the filename before the call to copy2(),
using the default file system encoding.

Matt Domsch authored on 2013/12/06 04:22:17
Showing 1 changed files
... ...
@@ -1000,7 +1000,8 @@ def local_copy(copy_pairs, destination_base):
1000 1000
                 debug("MKDIR %s" % dst_dir)
1001 1001
                 os.makedirs(dst_dir)
1002 1002
             debug(u"Copying %s to %s" % (src_file, dst_file))
1003
-            shutil.copy2(src_file, dst_file)
1003
+            encoding = sys.getfilesystemencoding()
1004
+            shutil.copy2(src_file.encode(encoding), dst_file.encode(encoding))
1004 1005
         except (IOError, OSError), e:
1005 1006
             warning(u'Unable to hardlink or copy files %s -> %s: %s' % (src_file, dst_file, e))
1006 1007
             failed_copy_list[relative_file] = src_obj