mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
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>
This commit is contained in:
parent
8f997b38cb
commit
b71d61d34e
@ -16,6 +16,7 @@
|
||||
|
||||
import errno
|
||||
|
||||
from pyversion import is_python3
|
||||
from ctypes import WinDLL, get_last_error, FormatError, WinError, addressof
|
||||
from ctypes import c_buffer
|
||||
from ctypes.wintypes import BOOL, BOOLEAN, LPCWSTR, DWORD, HANDLE, POINTER, c_ubyte
|
||||
@ -208,6 +209,10 @@ def readlink(path):
|
||||
|
||||
def _preserve_encoding(source, target):
|
||||
"""Ensures target is the same string type (i.e. unicode or str) as source."""
|
||||
|
||||
if is_python3():
|
||||
return target
|
||||
|
||||
if isinstance(source, unicode):
|
||||
return unicode(target)
|
||||
return str(target)
|
||||
|
Loading…
Reference in New Issue
Block a user