aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2014-10-19 13:02:37 +0100
committerJason R. Coombs <jaraco@jaraco.com>2014-10-19 13:02:37 +0100
commitae6eb3131a935824d1aca43c6ac5ac6bb4907078 (patch)
treeef06beac9a016ffd4aa2ac8e020d3a557aa408e5
parent3d532f52850f0c860f0031519a25231797320976 (diff)
downloadexternal_python_setuptools-ae6eb3131a935824d1aca43c6ac5ac6bb4907078.tar.gz
external_python_setuptools-ae6eb3131a935824d1aca43c6ac5ac6bb4907078.tar.bz2
external_python_setuptools-ae6eb3131a935824d1aca43c6ac5ac6bb4907078.zip
Declare argtypes and restype on SetFileAttributesW so that it will cast Python 2 bytestrings to Unicode automatically.
-rw-r--r--setuptools/dist.py4
-rw-r--r--setuptools/windows_support.py9
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()