Commit 0fb87f9b authored by Martin v. Löwis's avatar Martin v. Löwis

Explicitly encode data as UTF-8 before writing to a binary file.

--HG--
branch : distribute
extra : rebase_source : c9de4f92e3e50dd88fd1d29e2a9b2f3288fd4b88
parent 12054218
......@@ -3,7 +3,7 @@
Create a distribution's .egg-info directory and contents"""
# This module should be kept compatible with Python 2.3
import os, re
import os, re, sys
from setuptools import Command
from distutils.errors import *
from distutils import log
......@@ -148,6 +148,8 @@ class egg_info(Command):
to the file.
"""
log.info("writing %s to %s", what, filename)
if sys.version_info >= (3,):
data = data.encode("utf-8")
if not self.dry_run:
f = open(filename, 'wb')
f.write(data)
......@@ -351,8 +353,11 @@ def write_file (filename, contents):
"""Create a file with the specified name and write 'contents' (a
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("\n".join(contents))
f.write(contents)
f.close()
......
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