Commits

Stefan H. Holek committed aa664ca

When writing the manifest under Python 3, skip filenames that cannot be encoded to UTF-8.

  • Participants
  • Parent commits 823f784

Comments (0)

Files changed (2)

setuptools/command/egg_info.py

         by 'add_defaults()' and 'read_template()') to the manifest file
         named by 'self.manifest'.
         """
+        # The manifest must be UTF-8 encodable. See #303.
+        if sys.version_info >= (3,):
+            files = []
+            for file in self.filelist.files:
+                try:
+                    file.encode("utf-8")
+                except UnicodeEncodeError:
+                    log.warn("'%s' not UTF-8 encodable -- skipping" % file)
+                else:
+                    files.append(file)
+            self.filelist.files = files
+
         files = self.filelist.files
         if os.sep!='/':
             files = [f.replace(os.sep,'/') for f in files]
     """
     contents = "\n".join(contents)
     if sys.version_info >= (3,):
-        contents = contents.encode("utf-8", "surrogateescape")
+        contents = contents.encode("utf-8")
     f = open(filename, "wb")        # always write POSIX-style manifest
     f.write(contents)
     f.close()

setuptools/command/sdist.py

         manifest = open(self.manifest, 'rbU')
         for line in manifest:
             if sys.version_info >= (3,):
-                line = line.decode('UTF-8', 'surrogateescape')
+                line = line.decode('UTF-8')
             # ignore comments and blank lines
             line = line.strip()
             if line.startswith('#') or not line: