Commits

Daniel Holth committed f308fe7

incorrect (but exception-preventing) Py3 unicode handling

Unicode characters in Description wind up outputting ?? instead of failing.

Comments (0)

Files changed (1)

wheel/bdist_wheel.py

         description = pkg_info['Description']
         if description:
             del pkg_info['Description']
+
+            # Python 3 Unicode handling, sorta.
+            # There is a double-encoding bug in here somewhere.
+            use_surrogates = not isinstance(description, str)
+            description = str(description)
+
             description_lines = description.splitlines()
             description_dedent = '\n'.join(
                     # if the first line of long_description is blank,
                     (description_lines[0].lstrip(),
                      textwrap.dedent('\n'.join(description_lines[1:])),
                      '\n'))
+
+            if use_surrogates:
+                description_dedent = description_dedent\
+                        .encode("utf8")\
+                        .decode("ascii", "surrogateescape")
+
             pkg_info.set_payload(description_dedent)
         return pkg_info