Commit 60a42fcd authored by Philip Thiem's avatar Philip Thiem

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
parent 3f4f5b3b
"""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,):
#assuming the contents has been vetted for utf-8 encoding
contents = contents.encode("utf-8")
f = open(filename, "wb") # always write POSIX-style manifest
with open(filename, "wb") as f: # always write POSIX-style manifest
f.write(contents)
f.close()
def write_pkg_info(cmd, basename, filename):
log.info("writing %s", filename)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment