aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsetuptools/command/sdist.py3
-rw-r--r--setuptools/tests/test_sdist.py9
2 files changed, 8 insertions, 4 deletions
diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py
index d5259c2b..79eed214 100755
--- a/setuptools/command/sdist.py
+++ b/setuptools/command/sdist.py
@@ -283,7 +283,8 @@ class sdist(_sdist):
manifest = open(self.manifest, 'rbU')
for line in manifest:
if sys.version_info >= (3,):
- line = line.decode('UTF-8')
+ # Don't break if surrogates have crept into the manifest
+ line = line.decode('UTF-8', 'surrogateescape')
# 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 378015a8..04b3db66 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_read_manifest_rejects_surrogates(self):
+ def test_manifest_is_read_with_surrogateescape_error_handler(self):
# Test for #303.
# This is hard to test on HFS Plus because it quotes unknown
@@ -286,11 +286,14 @@ class TestSdistTest(unittest.TestCase):
manifest = open(cmd.manifest, 'ab')
manifest.write(filename+b('\n'))
manifest.close()
+ # Re-read manifest
+ try:
+ cmd.read_manifest()
+ except UnicodeDecodeError, e:
+ self.fail(e)
finally:
unquiet()
- self.assertRaises(UnicodeDecodeError, cmd.read_manifest)
-
def test_sdist_with_utf8_encoded_filename(self):
# Test for #303.
dist = Distribution(SETUP_ATTRS)