From acf63b28928b33d1335dfed1af7e2d8fc6bb5fc4 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 13 Jun 2019 02:24:21 -0400 Subject: 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 Tested-by: Mike Frysinger --- platform_utils_win32.py | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) (limited to 'platform_utils_win32.py') diff --git a/platform_utils_win32.py b/platform_utils_win32.py index 26c8ad42..bf916d47 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 @@ def readlink(path): '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) -- cgit v1.2.3-54-g00ecf