Commit 3b26424a authored by Stefan H. Holek's avatar Stefan H. Holek

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

--HG--
branch : distribute
extra : rebase_source : f1b439267fce37754aac49af15a9e26346950a26
parent a3966d17
......@@ -323,6 +323,18 @@ class manifest_maker(sdist):
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]
......@@ -360,7 +372,7 @@ def write_file (filename, contents):
"""
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()
......
......@@ -283,7 +283,7 @@ class sdist(_sdist):
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:
......
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