Commit f266bc37 authored by Stefan H. Holek's avatar Stefan H. Holek

Skip undecodable filenames in read_manifest as well.

--HG--
branch : distribute
extra : rebase_source : 2dda494b1a4758e84dde81cc61170acd0e55d2f2
parent e485c190
......@@ -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:
......
......@@ -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)
......
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