1. Tarek Ziadé
  2. distribute


Martin von Löwis  committed 782a7c3

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

  • Participants
  • Parent commits 19ec2ac
  • Branches 0.6-maintenance

Comments (0)

Files changed (1)

File setuptools/command/egg_info.py

View file
 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
         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')
     """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)