This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Distutils tries to handle null versions but fails
Type: behavior Stage: resolved
Components: Distutils Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: eric.araujo Nosy List: alexis, bgamari, dstufft, eric.araujo, steve.dower, tarek
Priority: normal Keywords: easy, patch

Created on 2011-09-28 19:32 by bgamari, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
distutils-fix.patch bgamari, 2011-09-28 19:32
distutils-workaround.patch bgamari, 2011-09-28 19:32
Pull Requests
URL Status Linked Edit
PR 12126 closed python-dev, 2019-03-01 15:34
Messages (7)
msg144575 - (view) Author: Ben Gamari (bgamari) Date: 2011-09-28 19:32
The distutils.LooseVersion constructor currently only calls parse if vstring has a value. Unfortunately, this means that a user passing in vstring="" or vstring=None gets a version object with self.vstring and self.version unset. This wreaks havoc later when the user tries to do anything with their object. I've attached two possible solutions.

The first attempts to fix the issue by raising an exception when an invalid vstring is given. This seems like the most reasonable treatment of this case as there is no reasonable way to fully initialize the object. The second works around the issue, initializing the uninitialized fields with "" in the event of an invalid vstring.
msg144899 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-10-04 16:35
Thanks, will fix it.
msg145239 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-10-09 09:03
The fact that 1) StrictVersion and LooseVersion have None as default argument for vstring in __init__ 2) __init__ does not raise an exception if vstring is not given makes me think that the intended behavior is that the vstring argument is optional.  Making it required would be a behavior change which would run contrary to the distutils code freeze*.  I don’t feel that the workaround (set self.vstring to '') is okay; I’d rather fix the methods that fail when self.vstring is not defined, like __str__, or document the limitations.  What is your use case for these classes, and what methods need fixing?

* There is a lot of code out there that will break if we start to add and remove
  things, so a freeze was decided and we work on distutils2, a new version.
  distutils only gets fixes for real bugs.
msg145255 - (view) Author: Ben Gamari (bgamari) Date: 2011-10-09 13:51
The bug was encountered while trying to install a package. As it turns out, a dependency was incorrectly installed, resulting in a null version being passed around which quickly caused a crash in setup.py. While this is definitely not a normal circumstance, the fact that this bug existed made finding the issue substantially more time consuming. If the constructor of the LooseVersion can accept None, then so should its other members.
msg145304 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-10-10 15:38
> The bug was encountered while trying to install a package. As it turns
> out, a dependency was incorrectly installed, resulting in a null
> version being passed around which quickly caused a crash in setup.py.
> While this is definitely not a normal circumstance, the fact that this
> bug existed made finding the issue substantially more time consuming.
I agree.  You don’t happen to have the log available, do you?

> If the constructor of the LooseVersion can accept None, then so should
> its other members.
Sure.  From a quick glance, we need to fix __str__ and _cmp.
msg145315 - (view) Author: Ben Gamari (bgamari) Date: 2011-10-10 22:49
Sorry, no log is available.
msg386311 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-02-03 18:16
Distutils is now deprecated (see PEP 632) and all tagged issues are being closed. From now until removal, only release blocking issues will be considered for distutils.

If this issue does not relate to distutils, please remove the component and reopen it. If you believe it still requires a fix, most likely the issue should be re-reported at https://github.com/pypa/setuptools
History
Date User Action Args
2022-04-11 14:57:22adminsetgithub: 57264
2021-02-03 18:16:25steve.dowersetstatus: open -> closed

nosy: + steve.dower
messages: + msg386311

resolution: out of date
stage: patch review -> resolved
2019-03-01 15:34:35python-devsetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request12129
2014-06-29 00:06:15BreamoreBoysetnosy: + dstufft

components: - Distutils2
versions: + Python 3.4, Python 3.5, - 3rd party, Python 3.2, Python 3.3
2011-10-10 22:49:15bgamarisetmessages: + msg145315
2011-10-10 15:38:13eric.araujosetkeywords: + easy, - patch

messages: + msg145304
stage: test needed -> needs patch
2011-10-09 13:51:11bgamarisetmessages: + msg145255
2011-10-09 09:03:14eric.araujosetmessages: + msg145239
2011-10-04 16:35:35eric.araujosetversions: + 3rd party, Python 3.2, Python 3.3
nosy: + alexis

messages: + msg144899

assignee: tarek -> eric.araujo
components: + Distutils2
2011-09-29 00:00:36ezio.melottisettype: crash -> behavior
stage: test needed
2011-09-28 19:32:35bgamarisetversions: + Python 2.7
nosy: + eric.araujo, tarek

assignee: tarek
components: + Distutils
type: crash
2011-09-28 19:32:14bgamarisetfiles: + distutils-workaround.patch
2011-09-28 19:32:02bgamaricreate