aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan H. Holek <stefan@epy.co.at>2012-11-01 11:47:24 +0100
committerStefan H. Holek <stefan@epy.co.at>2012-11-01 11:47:24 +0100
commitf266bc3745169122fcfcacb781e7e3c70fc58bfb (patch)
treef5c1f94bea7a5fb9edbca9ea8667d0f5b919b6c5
parente485c19015d4fced68b25c09ca66a1743d3ab27c (diff)
downloadexternal_python_setuptools-f266bc3745169122fcfcacb781e7e3c70fc58bfb.tar.gz
external_python_setuptools-f266bc3745169122fcfcacb781e7e3c70fc58bfb.tar.bz2
external_python_setuptools-f266bc3745169122fcfcacb781e7e3c70fc58bfb.zip
Skip undecodable filenames in read_manifest as well.
--HG-- branch : distribute extra : rebase_source : 2dda494b1a4758e84dde81cc61170acd0e55d2f2
-rwxr-xr-xsetuptools/command/sdist.py7
-rw-r--r--setuptools/tests/test_sdist.py8
2 files changed, 11 insertions, 4 deletions
diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py
index 79eed214..7a6d2b7d 100755
--- a/setuptools/command/sdist.py
+++ b/setuptools/command/sdist.py
@@ -283,8 +283,11 @@ class sdist(_sdist):
manifest = open(self.manifest, 'rbU')
for line in manifest:
if sys.version_info >= (3,):
- # Don't break if surrogates have crept into the manifest
- line = line.decode('UTF-8', 'surrogateescape')
+ try:
+ line = line.decode('UTF-8')
+ except UnicodeDecodeError:
+ log.warn("%r not UTF-8 decodable -- skipping" % line)
+ continue
# ignore comments and blank lines
line = line.strip()
if line.startswith('#') or not line:
diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py
index 04b3db66..a596f4bd 100644
--- a/setuptools/tests/test_sdist.py
+++ b/setuptools/tests/test_sdist.py
@@ -262,7 +262,7 @@ class TestSdistTest(unittest.TestCase):
# Python 3 only
if sys.version_info >= (3,):
- def test_manifest_is_read_with_surrogateescape_error_handler(self):
+ def test_read_manifest_skips_non_utf8_filenames(self):
# Test for #303.
# This is hard to test on HFS Plus because it quotes unknown
@@ -277,6 +277,7 @@ class TestSdistTest(unittest.TestCase):
cmd.ensure_finalized()
filename = os.path.join(b('sdist_test'), LATIN1_FILENAME)
+ u_filename = filename.decode('latin-1')
quiet()
try:
@@ -284,7 +285,7 @@ class TestSdistTest(unittest.TestCase):
# Add Latin-1 filename to manifest
cmd.manifest = os.path.join('sdist_test.egg-info', 'SOURCES.txt')
manifest = open(cmd.manifest, 'ab')
- manifest.write(filename+b('\n'))
+ manifest.write(b('\n')+filename)
manifest.close()
# Re-read manifest
try:
@@ -294,6 +295,9 @@ class TestSdistTest(unittest.TestCase):
finally:
unquiet()
+ # The Latin-1 filename should have been skipped
+ self.assertFalse(u_filename in cmd.filelist.files)
+
def test_sdist_with_utf8_encoded_filename(self):
# Test for #303.
dist = Distribution(SETUP_ATTRS)