diff options
| author | Philip Thiem <ptthiem@gmail.com> | 2014-05-17 02:40:07 -0500 |
|---|---|---|
| committer | Philip Thiem <ptthiem@gmail.com> | 2014-05-17 02:40:07 -0500 |
| commit | 60a42fcd2ae461bac7bbe93af92a9d7e0d13b746 (patch) | |
| tree | c207a704eacf682010052f139bc2fc8eb97d41bc | |
| parent | 3f4f5b3b4432203163258083f9e29b75d2aaedc4 (diff) | |
| download | python-setuptools-git-60a42fcd2ae461bac7bbe93af92a9d7e0d13b746.tar.gz | |
with_statements and output utf-8 output
*Since py2.5 has been dropped, we can use future imports to
make use of with statements.
*End goal was to always decode to utf-8 in write_file on 307
--HG--
extra : rebase_source : 502ea7128f4e3b843b16c6d64d6d0b2ac56ce87d
| -rwxr-xr-x | setuptools/command/egg_info.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 2097f2a9..1eca04ad 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -1,6 +1,7 @@ """setuptools.command.egg_info Create a distribution's .egg-info directory and contents""" +from __future__ import with_statement import os import re @@ -10,7 +11,7 @@ from setuptools import Command import distutils.errors from distutils import log from setuptools.command.sdist import sdist -from setuptools.compat import basestring, PY3 +from setuptools.compat import basestring, PY3, unicode from setuptools import svn_utils from distutils.util import convert_path from distutils.filelist import FileList as _FileList @@ -303,11 +304,13 @@ def write_file(filename, contents): sequence of strings without line terminators) to it. """ contents = "\n".join(contents) - if sys.version_info >= (3,): - contents = contents.encode("utf-8") - f = open(filename, "wb") # always write POSIX-style manifest - f.write(contents) - f.close() + + #assuming the contents has been vetted for utf-8 encoding + contents = contents.encode("utf-8") + + with open(filename, "wb") as f: # always write POSIX-style manifest + f.write(contents) + def write_pkg_info(cmd, basename, filename): log.info("writing %s", filename) |
