Fix distutils’ check and register Unicode handling (#13114).
The check command was fixed by Kirill Kuzminykh.
The register command was using StringIO.getvalue, which uses “''.join”
and thus coerces to str using the default encoding (ASCII), so I changed
the code to use one extra intermediary list and correctly encode to
UTF-8.
diff --git a/Lib/distutils/command/check.py b/Lib/distutils/command/check.py
index bc29baa..4b64e45 100644
--- a/Lib/distutils/command/check.py
+++ b/Lib/distutils/command/check.py
@@ -5,6 +5,7 @@
__revision__ = "$Id$"
from distutils.core import Command
+from distutils.dist import PKG_INFO_ENCODING
from distutils.errors import DistutilsSetupError
try:
@@ -108,6 +109,8 @@
def check_restructuredtext(self):
"""Checks if the long string fields are reST-compliant."""
data = self.distribution.get_long_description()
+ if not isinstance(data, unicode):
+ data = data.decode(PKG_INFO_ENCODING)
for warning in self._check_rst_data(data):
line = warning[-1].get('line')
if line is None: