classification
Title: Crash on distutils/util.py when header variable isn't a string
Type: crash Stage: resolved
Components: Library (Lib) Versions: Python 3.8
process
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.

Files
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
Hello,

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

--------------------------------

$ pip3 install bzr
Collecting bzr
  Using cached https://files.pythonhosted.org/packages/62/3a/81325e34bcc78f67cc33dfac64f44e7c8329d4481dec1b789267b98644c3/bzr-2.7.0.tar.gz
    ERROR: Complete output from command python setup.py 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/setup.py", line 781, in <module>
        setup(**ARGS)
      File "distutils/core.py", line 148, in setup
        dist.run_commands()
      File "distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "setuptools/command/egg_info.py", line 289, in run
        writer(self, ep.name, os.path.join(self.egg_info, ep.name))
      File "setuptools/command/egg_info.py", line 621, in write_pkg_info
        metadata.write_pkg_info(cmd.egg_info)
      File "distutils/dist.py", line 1117, in write_pkg_info
        self.write_pkg_file(pkg_info)
      File "setuptools/dist.py", line 165, in write_pkg_file
        long_desc = rfc822_escape(self.get_long_description())
      File "distutils/util.py", 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.

https://launchpad.net/brz
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.
History
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