aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan H. Holek <stefan@epy.co.at>2012-10-25 23:45:25 +0200
committerStefan H. Holek <stefan@epy.co.at>2012-10-25 23:45:25 +0200
commit3b26424a5a614cbed17f17591f91ec453be9d038 (patch)
tree97fcc19a4be3b193e92c84a91ddea1d3aeb14dc6
parenta3966d17f6f7f0769b83d5ef56fc8f97f6a4b415 (diff)
downloadexternal_python_setuptools-3b26424a5a614cbed17f17591f91ec453be9d038.tar.gz
external_python_setuptools-3b26424a5a614cbed17f17591f91ec453be9d038.tar.bz2
external_python_setuptools-3b26424a5a614cbed17f17591f91ec453be9d038.zip
When writing the manifest under Python 3, skip filenames that cannot be encoded to UTF-8.
--HG-- branch : distribute extra : rebase_source : f1b439267fce37754aac49af15a9e26346950a26
-rwxr-xr-xsetuptools/command/egg_info.py14
-rwxr-xr-xsetuptools/command/sdist.py2
2 files changed, 14 insertions, 2 deletions
diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py
index 9955c8ef..6e3d67af 100755
--- a/setuptools/command/egg_info.py
+++ b/setuptools/command/egg_info.py
@@ -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()
diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py
index 42558143..d5259c2b 100755
--- a/setuptools/command/sdist.py
+++ b/setuptools/command/sdist.py
@@ -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: