]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Don't encode unicode dirname in test_support.temp_cwd() if unicode file names
authorSerhiy Storchaka <storchaka@gmail.com>
Wed, 9 Sep 2015 09:18:36 +0000 (12:18 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Wed, 9 Sep 2015 09:18:36 +0000 (12:18 +0300)
are supported by the filesystem.  On Windows the encoding can convert some
characters to '?' that is not legal in file name.

Lib/test/test_support.py

index b578bcd6a7916a1a5b9a8fbe95ef21459f5464b6..7ce1c73b28ce4375af4faf9e5c0a13715ef4995b 100644 (file)
@@ -705,7 +705,8 @@ def temp_cwd(name='tempcwd', quiet=False):
     the CWD, an error is raised.  If it's True, only a warning is raised
     and the original CWD is used.
     """
-    if have_unicode and isinstance(name, unicode):
+    if (have_unicode and isinstance(name, unicode) and
+        not os.path.supports_unicode_filenames):
         try:
             name = name.encode(sys.getfilesystemencoding() or 'ascii')
         except UnicodeEncodeError: