From ae6eb3131a935824d1aca43c6ac5ac6bb4907078 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 19 Oct 2014 13:02:37 +0100 Subject: Declare argtypes and restype on SetFileAttributesW so that it will cast Python 2 bytestrings to Unicode automatically. --- setuptools/windows_support.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'setuptools/windows_support.py') diff --git a/setuptools/windows_support.py b/setuptools/windows_support.py index 8da71243..df35a5f4 100644 --- a/setuptools/windows_support.py +++ b/setuptools/windows_support.py @@ -1,4 +1,4 @@ -import ctypes +import ctypes.wintypes def hide_file(path): @@ -9,11 +9,12 @@ def hide_file(path): `path` must be text. """ - - SetFileAttributesW = ctypes.windll.kernel32.SetFileAttributesW + SetFileAttributes = ctypes.windll.kernel32.SetFileAttributesW + SetFileAttributes.argtypes = ctypes.wintypes.LPWSTR, ctypes.wintypes.DWORD + SetFileAttributes.restype = ctypes.wintypes.BOOL FILE_ATTRIBUTE_HIDDEN = 0x02 - ret = SetFileAttributesW(path, FILE_ATTRIBUTE_HIDDEN) + ret = SetFileAttributes(path, FILE_ATTRIBUTE_HIDDEN) if not ret: raise ctypes.WinError() -- cgit v1.2.1