Stefan H. Holek avatar Stefan H. Holek committed 638de15

Skip undecodable filenames in read_manifest as well.

Comments (0)

Files changed (2)

setuptools/command/sdist.py

         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:

setuptools/tests/test_sdist.py

     # 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
             cmd.ensure_finalized()
 
             filename = os.path.join(b('sdist_test'), LATIN1_FILENAME)
+            u_filename = filename.decode('latin-1')
 
             quiet()
             try:
                 # 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:
             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)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.