Title: Crash on distutils/ when header variable isn't a string
Type: crash Stage: resolved
Components: Library (Lib) Versions: Python 3.8
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: Lealinux, vstinner
Priority: normal Keywords: patch

Created on 2019-10-24 11:20 by Lealinux, last changed 2019-10-24 13:49 by vstinner. This issue is now closed.

File name Uploaded Description Edit
distutils_rfc822_escape.patch Lealinux, 2019-10-24 11:20 distutils_rfc822_escape.patch
Messages (4)
msg355326 - (view) Author: Lealinux (Lealinux) Date: 2019-10-24 11:20

With some pip3 package, distutils could crash if variable "header" isn't a real string variable :


$ pip3 install bzr
Collecting bzr
  Using cached
    ERROR: Complete output from command python egg_info:
    ERROR: running egg_info
    creating pip-egg-info/bzr.egg-info
    writing pip-egg-info/bzr.egg-info/PKG-INFO
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "pip-install/bzr/", line 781, in <module>
      File "distutils/", line 148, in setup
      File "distutils/", line 966, in run_commands
      File "distutils/", line 985, in run_command
      File "setuptools/command/", line 289, in run
        writer(self,, os.path.join(self.egg_info,
      File "setuptools/command/", line 621, in write_pkg_info
      File "distutils/", line 1117, in write_pkg_info
      File "setuptools/", line 165, in write_pkg_file
        long_desc = rfc822_escape(self.get_long_description())
      File "distutils/", line 470, in rfc822_escape
        lines = header.split('\n')
    TypeError: a bytes-like object is required, not 'str'


On this case (bzr), "header" is a bytes-like object.

On attachment, a patch proposal to have a (possible) solution

PS: newbie on python-core-patching and python-bug-report, sorry if we have missed something
msg355327 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-10-24 11:22
That sounds like a bug in bzr. You may try Breezy which supports Python 3.
msg355329 - (view) Author: Lealinux (Lealinux) Date: 2019-10-24 12:17
bzr (2.7) fail on install with pip3.7/pip3.8
breezy (3.x) success on install with pip3.7/pip3.8

We can forget the patch and close the report issue;
Sorry for the disturb :(
msg355331 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-10-24 13:49
I'm not sure of the status of bzr. Is it still maintained? It sounds like Breezy is the new upstream.

I don't think that it's worth it to bother with modifying distutils. Especially because it will take weeks or months until your system will get the fix.

I close the issue as rejected.
Date User Action Args
2019-10-24 13:49:19vstinnersetstatus: open -> closed
resolution: rejected
messages: + msg355331

stage: resolved
2019-10-24 12:17:14Lealinuxsetmessages: + msg355329
2019-10-24 11:22:49vstinnersetnosy: + vstinner
messages: + msg355327
2019-10-24 11:20:12Lealinuxcreate