Rev 4938: Better fix for fancy_rename respecting callers file encoding. in file:///home/vila/src/bzr/bugs/472161-ftp-utf8/

Vincent Ladeuil v.ladeuil+lp at free.fr
Wed Jan 13 13:56:31 GMT 2010


At file:///home/vila/src/bzr/bugs/472161-ftp-utf8/

------------------------------------------------------------
revno: 4938
revision-id: v.ladeuil+lp at free.fr-20100113135631-unwlvm2h2fkb12to
parent: v.ladeuil+lp at free.fr-20100107162712-otauyp8pfo0f9xov
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 472161-ftp-utf8
timestamp: Wed 2010-01-13 14:56:31 +0100
message:
  Better fix for fancy_rename respecting callers file encoding.
  
  * bzrlib/osutils.py:
  (fancy_rename): Don't force unicode on callers, some of them
  *requires* str objects.
-------------- next part --------------
=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py	2010-01-07 14:05:12 +0000
+++ b/bzrlib/osutils.py	2010-01-13 13:56:31 +0000
@@ -205,12 +205,14 @@
     :param unlink_func: A way to delete the target file if the full rename
         succeeds
     """
-    new = safe_unicode(new)
     # sftp rename doesn't allow overwriting, so play tricks:
     base = os.path.basename(new)
     dirname = os.path.dirname(new)
-    tmp_name = u'tmp.%s.%.9f.%d.%s' % (base, time.time(),
-                                       os.getpid(), rand_chars(10))
+    # callers use different encodings for the paths so the following MUST
+    # respect that. We rely on python upcasting to unicode if new is unicode
+    # and keeping a str if not.
+    tmp_name = 'tmp.%s.%.9f.%d.%s' % (base, time.time(),
+                                      os.getpid(), rand_chars(10))
     tmp_name = pathjoin(dirname, tmp_name)
 
     # Rename the file out of the way, but keep track if it didn't exist



More information about the bazaar-commits mailing list