aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2016-02-19 09:34:14 -0500
committerJason R. Coombs <jaraco@jaraco.com>2016-02-19 09:34:14 -0500
commite5f397829451be329a91838275977cebac45375d (patch)
treeb5a34b06e4897804c627360958d70080e4e5b9b3
parent8ccd428cd2a733891bffce13e017774ea82bd8d2 (diff)
downloadexternal_python_setuptools-e5f397829451be329a91838275977cebac45375d.tar.gz
external_python_setuptools-e5f397829451be329a91838275977cebac45375d.tar.bz2
external_python_setuptools-e5f397829451be329a91838275977cebac45375d.zip
Use io module and text type in install_site_py
-rwxr-xr-xsetuptools/command/easy_install.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index 46056173..08bc9c51 100755
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -1239,17 +1239,14 @@ class easy_install(Command):
sitepy = os.path.join(self.install_dir, "site.py")
source = resource_string("setuptools", "site-patch.py")
+ source = source.decode('utf-8')
current = ""
if os.path.exists(sitepy):
log.debug("Checking existing site.py in %s", self.install_dir)
- f = open(sitepy, 'rb')
- current = f.read()
- # we want str, not bytes
- if six.PY3:
- current = current.decode()
+ with io.open(sitepy) as strm:
+ current = strm.read()
- f.close()
if not current.startswith('def __boot():'):
raise DistutilsError(
"%s is not a setuptools-generated site.py; please"
@@ -1260,9 +1257,8 @@ class easy_install(Command):
log.info("Creating %s", sitepy)
if not self.dry_run:
ensure_directory(sitepy)
- f = open(sitepy, 'wb')
- f.write(source)
- f.close()
+ with io.open(sitepy, 'w', encoding='utf-8') as strm:
+ strm.write(source)
self.byte_compile([sitepy])
self.sitepy_installed = True