diff options
author | Rostislav Krasny <rostigm@gmail.com> | 2020-01-24 22:29:54 +0200 |
---|---|---|
committer | Rostislav Krasny <rostigm@gmail.com> | 2020-01-24 21:50:22 +0000 |
commit | b71d61d34e71d6a0f6a92355d6b6d4e91d9498fe (patch) | |
tree | 0e3585dd71654ab18d96b6bf686944a097a719ea /platform_utils_win32.py | |
parent | 8f997b38cbc762cbf6482bce3c96291e0b67bc1e (diff) | |
download | git-repo-b71d61d34e71d6a0f6a92355d6b6d4e91d9498fe.tar.gz |
Make _preserve_encoding in platform_utils_win32 compatible with Python 3
Bug: https://crbug.com/gerrit/12145
Change-Id: I01d1ef96ff7b474f55ed42ecc13bd5943006d3b5
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/251833
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Rostislav Krasny <rostigm@gmail.com>
Diffstat (limited to 'platform_utils_win32.py')
-rw-r--r-- | platform_utils_win32.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/platform_utils_win32.py b/platform_utils_win32.py index 31e00c17..b5c21fe0 100644 --- a/platform_utils_win32.py +++ b/platform_utils_win32.py | |||
@@ -16,6 +16,7 @@ | |||
16 | 16 | ||
17 | import errno | 17 | import errno |
18 | 18 | ||
19 | from pyversion import is_python3 | ||
19 | from ctypes import WinDLL, get_last_error, FormatError, WinError, addressof | 20 | from ctypes import WinDLL, get_last_error, FormatError, WinError, addressof |
20 | from ctypes import c_buffer | 21 | from ctypes import c_buffer |
21 | from ctypes.wintypes import BOOL, BOOLEAN, LPCWSTR, DWORD, HANDLE, POINTER, c_ubyte | 22 | from ctypes.wintypes import BOOL, BOOLEAN, LPCWSTR, DWORD, HANDLE, POINTER, c_ubyte |
@@ -208,6 +209,10 @@ def readlink(path): | |||
208 | 209 | ||
209 | def _preserve_encoding(source, target): | 210 | def _preserve_encoding(source, target): |
210 | """Ensures target is the same string type (i.e. unicode or str) as source.""" | 211 | """Ensures target is the same string type (i.e. unicode or str) as source.""" |
212 | |||
213 | if is_python3(): | ||
214 | return target | ||
215 | |||
211 | if isinstance(source, unicode): | 216 | if isinstance(source, unicode): |
212 | return unicode(target) | 217 | return unicode(target) |
213 | return str(target) | 218 | return str(target) |