drop pyversion & is_python3 checking
We're committed to Python 3 at this point, so purge all the
is_python3 related dynamic checks.
Bug: https://crbug.com/gerrit/10418
Change-Id: I4c8b405d6de359b8b83223c9f4b9c8ffa18ea1a2
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/292383
Reviewed-by: Chris Mcdonald <cjmcdonald@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
diff --git a/platform_utils_win32.py b/platform_utils_win32.py
index 26c8ad4..bf916d4 100644
--- a/platform_utils_win32.py
+++ b/platform_utils_win32.py
@@ -14,18 +14,10 @@
import errno
-from pyversion import is_python3
from ctypes import WinDLL, get_last_error, FormatError, WinError, addressof
-from ctypes import c_buffer
+from ctypes import c_buffer, c_ubyte, Structure, Union, byref
from ctypes.wintypes import BOOL, BOOLEAN, LPCWSTR, DWORD, HANDLE
-from ctypes.wintypes import WCHAR, USHORT, LPVOID, ULONG
-if is_python3():
- from ctypes import c_ubyte, Structure, Union, byref
- from ctypes.wintypes import LPDWORD
-else:
- # For legacy Python2 different imports are needed.
- from ctypes.wintypes import POINTER, c_ubyte, Structure, Union, byref
- LPDWORD = POINTER(DWORD)
+from ctypes.wintypes import WCHAR, USHORT, LPVOID, ULONG, LPDWORD
kernel32 = WinDLL('kernel32', use_last_error=True)
@@ -202,26 +194,15 @@
'Error reading symbolic link \"%s\"'.format(path))
rdb = REPARSE_DATA_BUFFER.from_buffer(target_buffer)
if rdb.ReparseTag == IO_REPARSE_TAG_SYMLINK:
- return _preserve_encoding(path, rdb.SymbolicLinkReparseBuffer.PrintName)
+ return rdb.SymbolicLinkReparseBuffer.PrintName
elif rdb.ReparseTag == IO_REPARSE_TAG_MOUNT_POINT:
- return _preserve_encoding(path, rdb.MountPointReparseBuffer.PrintName)
+ return rdb.MountPointReparseBuffer.PrintName
# Unsupported reparse point type
_raise_winerror(
ERROR_NOT_SUPPORTED,
'Error reading symbolic link \"%s\"'.format(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): # noqa: F821
- return unicode(target) # noqa: F821
- return str(target)
-
-
def _raise_winerror(code, error_desc):
win_error_desc = FormatError(code).strip()
error_desc = "%s: %s".format(error_desc, win_error_desc)