diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2014-10-19 13:02:37 +0100 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2014-10-19 13:02:37 +0100 |
commit | 39a920265a6754fb438aa358b58aed91c1a0adb9 (patch) | |
tree | ae5879ac4d0d5649ff5adda04b6c8c7a9ec7bc8a | |
parent | 7ac30f9142fc7a5b8116ffe7e1ee0a7d2350a2e5 (diff) | |
download | python-setuptools-bitbucket-39a920265a6754fb438aa358b58aed91c1a0adb9.tar.gz |
Declare argtypes and restype on SetFileAttributesW so that it will cast Python 2 bytestrings to Unicode automatically.
-rw-r--r-- | setuptools/dist.py | 4 | ||||
-rw-r--r-- | setuptools/windows_support.py | 9 |
2 files changed, 7 insertions, 6 deletions
diff --git a/setuptools/dist.py b/setuptools/dist.py index 4f302232..6b9d350e 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -14,7 +14,7 @@ from distutils.errors import (DistutilsOptionError, DistutilsPlatformError, DistutilsSetupError) from setuptools.depends import Require -from setuptools.compat import basestring, PY2, unicode +from setuptools.compat import basestring, PY2 from setuptools import windows_support import pkg_resources @@ -310,7 +310,7 @@ class Distribution(_Distribution): egg_cache_dir = os.path.join(os.curdir, '.eggs') if not os.path.exists(egg_cache_dir): os.mkdir(egg_cache_dir) - windows_support.hide_file(unicode(egg_cache_dir)) + windows_support.hide_file(egg_cache_dir) readme_txt_filename = os.path.join(egg_cache_dir, 'README.txt') with open(readme_txt_filename, 'w') as f: f.write('This directory contains eggs that were downloaded ' 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() |