summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2019-04-05 18:00:49 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2019-04-05 18:00:49 +0000
commit50e609611c9c70c689fb26f2fcee32dd0399dd61 (patch)
treea29a5be6a1ac221048f300ac14fa8099b735e4c4
parent5eeb28f8e0cc9117c7b8702b3469160746ff6fd5 (diff)
downloadbcm5719-llvm-50e609611c9c70c689fb26f2fcee32dd0399dd61.tar.gz
bcm5719-llvm-50e609611c9c70c689fb26f2fcee32dd0399dd61.zip
lit: make rm python 3 friendly (NFC)
Add some alterations for python 3 compatibility. llvm-svn: 357789
-rw-r--r--llvm/utils/lit/lit/TestRunner.py12
-rw-r--r--llvm/utils/lit/lit/util.py2
2 files changed, 8 insertions, 6 deletions
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 8a1842f147a..07b0021385b 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -617,10 +617,10 @@ def executeBuiltinRm(cmd, cmd_shenv):
# NOTE: use ctypes to access `SHFileOperationsW` on Windows to
# use the NT style path to get access to long file paths which
# cannot be removed otherwise.
- from ctypes.wintypes import BOOL, HWND, LPCWSTR, POINTER, UINT, WORD
- from ctypes import c_void_p, byref
+ from ctypes.wintypes import BOOL, HWND, LPCWSTR, UINT, WORD
+ from ctypes import addressof, byref, c_void_p, create_unicode_buffer
from ctypes import Structure
- from ctypes import windll, WinError
+ from ctypes import windll, WinError, POINTER
class SHFILEOPSTRUCTW(Structure):
_fields_ = [
@@ -634,7 +634,7 @@ def executeBuiltinRm(cmd, cmd_shenv):
('lpszProgressTitle', LPCWSTR),
]
- FO_MOVE, FO_COPY, FO_DELETE, FO_RENAME = xrange(1, 5)
+ FO_MOVE, FO_COPY, FO_DELETE, FO_RENAME = range(1, 5)
FOF_SILENT = 4
FOF_NOCONFIRMATION = 16
@@ -648,8 +648,10 @@ def executeBuiltinRm(cmd, cmd_shenv):
path = os.path.abspath(path)
+ pFrom = create_unicode_buffer(path, len(path) + 2)
+ pFrom[len(path)] = pFrom[len(path) + 1] = '\0'
operation = SHFILEOPSTRUCTW(wFunc=UINT(FO_DELETE),
- pFrom=LPCWSTR(unicode(path + '\0')),
+ pFrom=LPCWSTR(addressof(pFrom)),
fFlags=FOF_NO_UI)
result = SHFileOperationW(byref(operation))
if result:
diff --git a/llvm/utils/lit/lit/util.py b/llvm/utils/lit/lit/util.py
index 3b1391115a5..8b346f700b0 100644
--- a/llvm/utils/lit/lit/util.py
+++ b/llvm/utils/lit/lit/util.py
@@ -149,7 +149,7 @@ def mkdir(path):
from ctypes import GetLastError, WinError
path = os.path.abspath(path)
- NTPath = unicode(r'\\?\%s' % path)
+ NTPath = to_unicode(r'\\?\%s' % path)
if not windll.kernel32.CreateDirectoryW(NTPath, None):
raise WinError(GetLastError())
else:
OpenPOWER on IntegriCloud