homepage

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: "dist must be a Distribution instance" check fails with setuptools
Type: behavior Stage: resolved
Components: Distutils Versions: Python 3.4, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: distutils: isinstance checks fail with setuptools-monkeypatched Extension/Distribution
View: 23102
Assigned To: Nosy List: dstufft, eric.araujo, ralf.gommers, scoder
Priority: normal Keywords:

Created on 2014年12月26日 10:30 by scoder, last changed 2022年04月11日 14:58 by admin. This issue is now closed.

Messages (3)
msg233104 - (view) Author: Stefan Behnel (scoder) * (Python committer) Date: 2014年12月26日 10:30
distutils uses this code to validate the input in "Command.__init__()":
 # late import because of mutual dependence between these classes
 from distutils.dist import Distribution
 if not isinstance(dist, Distribution):
 raise TypeError, "dist must be a Distribution instance"
(Lib/distutils/cmd.py, after line 50)
This fails if the calling code uses the stdlib Distribution type (e.g. with a module global import) but setuptools was only imported afterwards and replaced "distutils.dist.Distribution" with its own implementation. In this case, the above code will get hold of the setuptools implementation and the isinstance() check will fail as both classes are not compatible.
I guess this is a problem more in setuptools than in distutils, but a) this isinstance() check has a general code smell and b) pip and setuptools are automatically installed in a specific (impacted) version in Py2.7.9 and Py3.4, which makes this problem quite pressing for the stdlib side.
msg233110 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2014年12月26日 17:17
Can this ticket be merged into #23102 ?
msg233112 - (view) Author: Stefan Behnel (scoder) * (Python committer) Date: 2014年12月26日 18:53
Yes, pretty much the same problem.
History
Date User Action Args
2022年04月11日 14:58:11adminsetgithub: 67303
2016年02月13日 17:20:57ralf.gommerssetnosy: + ralf.gommers
2014年12月26日 18:54:56eric.araujosetstatus: open -> closed
superseder: distutils: isinstance checks fail with setuptools-monkeypatched Extension/Distribution
resolution: duplicate
stage: resolved
2014年12月26日 18:53:40scodersetmessages: + msg233112
2014年12月26日 17:17:29eric.araujosetmessages: + msg233110
2014年12月26日 10:30:55scodercreate

AltStyle によって変換されたページ (->オリジナル) /