From 3eb5ff9e15c8ed4e3b22321df980771d4fb2ee46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Fri, 4 Dec 2020 12:00:30 +0200 Subject: [PATCH] Fixed TypeError when a unicode generator name was passed on Python 2.7 Fixes #388. --- docs/news.rst | 6 ++++++ src/wheel/bdist_wheel.py | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/docs/news.rst b/docs/news.rst index 1812e122..debb4122 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -1,6 +1,12 @@ Release Notes ============= +**UNRELEASED** + +- Fixed regression introduced in 0.36.0 on Python 2.7 when a custom generator + name was passed as unicode (Scikit-build) + (``TypeError: 'unicode' does not have the buffer interface``) + **0.36.0 (2020-12-01)** - Added official Python 3.9 support diff --git a/src/wheel/bdist_wheel.py b/src/wheel/bdist_wheel.py index 9c9b0a88..80e43d0a 100644 --- a/src/wheel/bdist_wheel.py +++ b/src/wheel/bdist_wheel.py @@ -373,6 +373,11 @@ def run(self): def write_wheelfile(self, wheelfile_base, generator='bdist_wheel (' + wheel_version + ')'): from email.message import Message + + # Workaround for Python 2.7 for when "generator" is unicode + if sys.version_info < (3,) and not isinstance(generator, str): + generator = generator.encode('utf-8') + msg = Message() msg['Wheel-Version'] = '1.0' # of the spec msg['Generator'] = generator